#abc305h. Ex - Shojin
Ex - Shojin
Score : points
问题描述
你决定进行 练习。练习意味着在 AtCoder 上解决大量问题。 练习将持续数天。一天的练习按照以下步骤进行:
- 设 为当天需要解决的问题数量。每个问题都有一个称为 难度 的值,它是一对非负整数 。
- 首先,任意重新排列这 个问题,然后按照该顺序逐一解决问题。
- 你有一个称为 疲劳值 的数值。在一天开始时疲劳值为 ,当解决难度为 的问题时,疲劳值会从 变化到 。
- 解决完所有 个问题后的疲劳值被称为那天的 消耗能量。
AtCoder 中有一序列包含 个问题,依次称为问题 、问题 、、问题 。问题 的难度为 。
你决定通过练习来解决所有 个问题。
练习按以下步骤进行。下面,令 表示问题 、问题 、、问题 这一连续问题序列。
- 自由选择一个介于 到 (包括两端点)之间的整数 。练习将持续 天。
- 将包含 个问题的序列划分为 个非空连续子序列,并令第 个子序列记作 。
形式上,选择一个严格递增的非负整数序列 ,满足 和 ,并令 对于 。 - 然后,在练习的第 天,对于 ,解决子序列 中的所有问题。
你决定进行练习以确保整个练习期间消耗的总能量不超过 。
设 为满足此条件的练习所需天数 的最小可能值。(这里保证 。在此约束下,这样的 总是存在的。)
同时,设 为满足 时整个练习期间消耗的最小可能总能量。
求解 和 。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You have decided to practice. Practice means solving a large number of problems in AtCoder.
Practice takes place over several days. The practice for one day is carried out in the following steps.
- Let be the number of problems to be solved on that day. Each problem has a value called difficulty, which is a pair of non-negative integers .
- First, rearrange the problems in any order. Then, solve the problems one by one in that order.
- You have a value called fatigue. The fatigue at the beginning of the day is , and it changes from to when solving a problem with difficulty .
- The fatigue at the end of solving all problems is called the energy consumed for that day.
There is a sequence of problems in AtCoder, called problem , problem , , problem in order. The difficulty of problem is .
You have decided to solve all problems through practice.
Practice is carried out in the following steps. Below, let denote the following sequence of problems: problem , problem , , problem .
- Choose an integer freely between and , inclusive. The practice will last days.
- Divide the sequence of problems into non-empty continuous subsequences, and let be the -th sequence.
Formally, choose a strictly increasing non-negative integer sequence such that and , and let for . - Then, for , solve all problems in on the -th day of practice.
You have decided to practice so that the total energy consumed throughout the practice is at most .
Let be the minimum possible value of , the number of days, for such a practice. (Here, it is guaranteed that . Under this constraint, such always exists.)
Also, let be the minimum possible total energy consumed throughout a practice such that .
Find and .
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print and separated by a space.
Sample Input 1
3 100
2 2
3 4
5 7
Sample Output 1
1 52
In this test case, you can solve all problems in one day while satisfying the condition for .
By following the steps below, the total energy consumed during the practice will be , which is the minimum.
- Set and solve on the first day.
- Carry out the practice on the first day in the following steps.
- Arrange the problems in the order (problem , problem , problem ).
- Initially, the fatigue is .
- Solve problem . The fatigue changes to .
- Solve problem . The fatigue changes to .
- Solve problem . The fatigue changes to .
- The fatigue at the end of solving all problems is . Therefore, the energy consumed on this day is .
- The total energy consumed throughout the practice is also .
Sample Input 2
3 30
2 2
3 4
5 7
Sample Output 2
2 17
This test case is obtained by changing from to in the first test case. Therefore, it is impossible to solve all problems in one day while satisfying the condition for .
By following the steps below, you can achieve by practicing for two days.
- Set , and solve on the first day and on the second day.
- Carry out the practice on the first day in the following steps.
- Arrange the problems in the order (problem , problem ).
- Initially, the fatigue is .
- Solve problem . The fatigue changes to .
- Solve problem . The fatigue changes to .
- The fatigue at the end of solving all problems is . Therefore, the energy consumed on the first day is .
- Carry out the practice on the second day in the following steps.
- Arrange the problems in the order (problem ).
- Initially, the fatigue is .
- Solve problem . The fatigue changes to .
- The fatigue at the end of solving all problems is . Therefore, the energy consumed on the second day is .
- The total energy consumed throughout the practice is .
Sample Input 3
5 50000000
100000 10000000
100000 10000000
100000 10000000
100000 10000000
100000 10000000
Sample Output 3
5 50000000
The optimal practice is to solve one problem per day.
Sample Input 4
10 100000000
5 88
66 4
52 1
3 1
12 1
53 25
11 12
12 2
1 20
47 10
Sample Output 4
2 73647
Sample Input 5
15 100000000
2387 3178
2369 5772
1 29
36 3
52 2981
196 1
36 704
3 3
1501 5185
23 628
3623 810
80 101
6579 15
681 7
183 125
Sample Output 5
4 54468135
update @ 2024/3/10 08:37:51