CF1165F1.Microtransactions (easy version)
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
The only difference between easy and hard versions is constraints.
Ivan plays a computer game that contains some microtransactions to make characters look cooler. Since Ivan wants his character to be really cool, he wants to use some of these microtransactions — and he won't start playing until he gets all of them.
Each day (during the morning) Ivan earns exactly one burle.
There are n types of microtransactions in the game. Each microtransaction costs 2 burles usually and 1 burle if it is on sale. Ivan has to order exactly ki microtransactions of the i-th type (he orders microtransactions during the evening).
Ivan can order any (possibly zero) number of microtransactions of any types during any day (of course, if he has enough money to do it). If the microtransaction he wants to order is on sale then he can buy it for 1 burle and otherwise he can buy it for 2 burles.
There are also m special offers in the game shop. The j-th offer (dj,tj) means that microtransactions of the tj-th type are on sale during the dj-th day.
Ivan wants to order all microtransactions as soon as possible. Your task is to calculate the minimum day when he can buy all microtransactions he want and actually start playing.
简单版本与困难版本的唯一区别在于约束条件。
伊万正在玩一款电脑游戏,游戏中包含一些微交易,用于让角色外观更炫酷。由于伊万希望自己的角色真正酷炫,他打算购买其中若干微交易——并且他不会开始玩游戏,直到他获得全部所需的微交易为止。
每天(清晨),伊万恰好赚取 1 卢布(burle)。
游戏中共有 n 种微交易。通常情况下,每种微交易价格为 2 卢布;若该微交易处于促销状态,则仅需 1 卢布。伊万需要恰好购买第 i 种微交易 ki 个(他在每天傍晚下单)。
在任意一天(当然前提是他拥有足够资金),伊万可以购买任意数量(包括零个)的任意种类微交易。若他想购买的微交易正处于促销状态,则只需花费 1 卢布;否则需花费 2 卢布。
此外,游戏商店还提供 m 个特别优惠。第 j 个优惠 (dj,tj) 表示:在第 dj 天,第 tj 种微交易处于促销状态。
伊万希望尽快完成所有微交易的购买。你的任务是计算出他能够买齐所有所需微交易并真正开始游戏的最早天数。
输入格式
The first line of the input contains two integers n and m (1≤n,m≤1000) — the number of types of microtransactions and the number of special offers in the game shop.
The second line of the input contains n integers k1,k2,…,kn (0≤ki≤1000), where ki is the number of copies of microtransaction of the i-th type Ivan has to order. It is guaranteed that sum of all ki is not less than 1 and not greater than 1000.
The next m lines contain special offers. The j-th of these lines contains the j-th special offer. It is given as a pair of integers (dj,tj) (1≤dj≤1000,1≤tj≤n) and means that microtransactions of the tj-th type are on sale during the dj-th day.
输入的第一行包含两个整数 n 和 m(1≤n,m≤1000)——分别表示微交易类型的数量以及游戏商店中特价优惠的数量。
输入的第二行包含 n 个整数 k1,k2,…,kn(0≤ki≤1000),其中 ki 表示 Ivan 需要订购的第 i 种微交易的份数。保证所有 ki 的总和不小于 1 且不大于 1000。
接下来的 m 行描述特价优惠。其中第 j 行描述第 j 个特价优惠,以一对整数 (dj,tj)(1≤dj≤1000, 1≤tj≤n)给出,表示在第 dj 天,第 tj 种微交易正在促销。
输出格式
Print one integer — the minimum day when Ivan can order all microtransactions he wants and actually start playing.
输出一个整数——伊万能够订购所有他想要的微交易并真正开始游戏的最早天数。
输入输出样例
输入#1
5 6 1 2 0 2 0 2 4 3 3 1 5 1 2 1 5 2 3
输出#1
8
输入#2
5 3 4 2 1 3 2 3 5 4 2 2 5
输出#2
20
输入解题思路,AI测评打分。不知道怎么写?