#abc363g. G - Dynamic Scheduling
G - Dynamic Scheduling
Score : points
问题陈述
你有两个长度为 的序列: 和 。
按照给定的顺序处理 个查询。每个查询以以下格式给出:
c x y
: 将 改为 ,将 改为 。然后,解决以下问题并打印答案。
有 个工作,编号从 到 。 从今天开始(考虑为第 天),你将选择并完成一个工作,持续 天。 如果你在第 天或之前完成工作 ,你将获得 的奖励。(如果你在第 天之前没有完成,你将一无所获。) 通过选择完成工作的最优顺序,找到你可以实现的最大总奖励。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
You are given two sequences of length : and .
Process queries in the order they are given. Each query is given in the following format:
c x y
: Change to and to . Then, solve the following problem and print the answer.
There are jobs numbered to .
Starting from today (consider this as day ), you will choose and complete one job per day for days.
If you complete job on or before day , you will receive a reward of . (If you do not complete it by day , you get nothing.)
Find the maximum total reward you can achieve by choosing the optimal order of completing the jobs.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format. Here, denotes the -th query.
Each query is given in the following format.
Output
Print lines. The -th line should contain the answer to the -th query.
Sample Input 1
3 2
1 2 3
3 6 3
3 1 4
2 3 9
Sample Output 1
10
13
The first query is as follows:
- Update to and to . Now, and .
- In the subproblem, one optimal procedure is to complete job on day , job on day , and job on day . The total reward is , so print .
The second query is as follows:
- Update to and to . Now, and .
- In the subproblem, one optimal procedure is to complete job on day , job on day , and job on day . The total reward is , so print .
Sample Input 2
5 1
1 2 3 4 5
1000000000 1000000000 1000000000 1000000000 1000000000
1 1 1000000000
Sample Output 2
5000000000
Sample Input 3
10 10
6 2 4 1 5 1 6 6 5 3
45 65 71 52 86 52 48 60 40 98
5 6 5
8 4 34
6 7 83
1 3 21
7 5 85
7 4 51
8 2 81
2 7 54
6 1 5
8 6 30
Sample Output 3
394
379
462
457
459
414
443
479
401
396