DTOJ #2927. Around the world4

时间:2019-08-19
本文章向大家介绍DTOJ #2927. Around the world4,主要包括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.

Output

Print one integer — the minimum time one has to spent in order to prepare n potions.

Examples
input
Copy
20 3 2 10 99 2 4 3 20 10 40 4 15 10 80
output
Copy
20
input
Copy
20 3 2 10 99 2 4 3 200 100 400 4 15 100 800
output
Copy
200
Note

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),注意要单独算出两种魔法都不用,只用第一种魔法和只用第二种魔法的情况,这是本题的坑点

原文地址:https://www.cnblogs.com/xhf121012/p/11376348.html