CF2023B Skipping

题目描述

现在已经是3024年了,出题的想法早就枯竭。现今的OI以一种修改后的个人参赛形式进行。比赛有$n$道题,编号从$1$到$n$,一道题有一个分数$a_i$和一个参数$b_i$。最开始,评测系统会把第$1$道题丢给选手。当一个选手拿到第$i$道题,他有两个选择: - 提交,获得$a_i$分 - 跳过,但他再不能去交这道题了。 接下来,评测系统会把编号最大的符合下述条件的题目$j$丢给选手: - 如果选手提交了$i$题,那么$j

输入格式

输出格式

说明/提示

In the first test case, Prokhor can skip the first problem; then he will receive the problem with index $ b_1 = 2 $ . Prokhor can submit it and receive $ a_2 = 16 $ points. After that, the competition will end because Prokhor has already received all problems. Note that if Prokhor submits the first problem, he will receive $ a_1 = 15 $ points, but the competition will end immediately. In the second test case, Prokhor can skip the first problem; then he will receive the problem with index $ b_1 = 3 $ . Prokhor can submit it and receive $ a_3 = 100 $ points. After that, Prokhor will receive the second problem, which he can skip to receive the problem with index $ b_2 = 4 $ . Prokhor can submit the fourth problem and receive another $ a_4 = 100 $ points. After that, the competition ends because Prokhor has already received all problems with indices not exceeding $ 4 $ . Thus, Prokhor will receive a total of $ 200 $ points. In the third test case, Prokhor can submit the first problem and receive $ 100 $ points, after which the competition will end immediately.