DTOJ #2927. Around the world4
Posted xhf121012
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了DTOJ #2927. Around the world4相关的知识,希望对你有一定的参考价值。
The fourth line contains m integers bi (1 ≤ bi ≤ 2·109) — the number of manapoints to use the i-th spell of the first type.
There are k integers ci (1 ≤ ci ≤ n) in the fifth line — the number of potions that will be immediately created if the i-th spell of the second type is used. It‘s guaranteed that ci are not decreasing, i.e. ci ≤ cj if i < j.
The sixth line contains k integers di (1 ≤ di ≤ 2·109) — the number of manapoints required to use the i-th spell of the second type. It‘s guaranteed that di are not decreasing, i.e. di ≤ dj if i < j.
Print one integer — the minimum time one has to spent in order to prepare n potions.
20 3 2 10 99 2 4 3 20 10 40 4 15 10 80
20
20 3 2 10 99 2 4 3 200 100 400 4 15 100 800
200
In the first sample, the optimum answer is to use the second spell of the first type that costs 10 manapoints. Thus, the preparation time of each potion changes to 4 seconds. Also, Anton should use the second spell of the second type to instantly prepare 15 potions spending 80 manapoints. The total number of manapoints used is 10 + 80 = 90, and the preparation time is 4·5 = 20 seconds (15 potions were prepared instantly, and the remaining 5 will take 4 seconds each).
In the second sample, Anton can‘t use any of the spells, so he just prepares 20 potions, spending 10 seconds on each of them and the answer is 20·10 = 200.
题意: https://weibo.com/ttarticle/p/show?id=2309404406834504007712
有n瓶药,一开始做这n瓶药每瓶需要x的时间,现在有s块钱,并有两种魔法,每种魔法最多只能用一次(也就是说可用不用,这是坑点,要注意no more,at least之类的) 第一种魔法是把所有药的准备时间变为ai,花费是bi,第二种魔法是用0秒时间立刻做出ci个药,花费是di,注意input那指出第二种魔法的ci和di是非严格递增的
https://weibo.com/ttarticle/p/show?id=2309404406834504007712
https://weibo.com/ttarticle/p/show?id=2309404406830422949892
思路:
看到递增就想到了二分,所以就枚举第一种魔法,同时二分第二种魔法,复杂度O(mlogk),注意要单独算出两种魔法都不用,只用第一种魔法和只用第二种魔法的情况,这是本题的坑点
以上是关于DTOJ #2927. Around the world4的主要内容,如果未能解决你的问题,请参考以下文章
Run-Time Check Failure #2 - Stack around the variable 'a' was corrupted.
BZOJ 3827: [Poi2014]Around the world
UTT--Ethnicraft around the world[Ⅰ]
R语言ggplot2可视化删除图例(legend)周围的灰色矩形(remove the gray rectangle around the legend)
Array types are now written with the brackets around the element type问题的解决方法