#abc226c. C - Martial artist
C - Martial artist
Score : points
问题描述
Takahashi 是一名武术家。武术家中可以学习 种招式,分别称为第 、、、第 招。对于每种 的招式,学习第 招需要花费 分钟的练习时间。另外,在开始练习这一招式时,必须已经学会招式 、、、。这里保证对于每个 ,都有 。
在时间 时,Takahashi 还未学会任何招式。他不能同时练习超过一种招式,也不能在已经开始练习后中途停止。请找出 Takahashi 学会第 招所需的最短分钟数。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
Takahashi is a martial artist. There are moves that a martial artist can learn, called Move , , , . For each , it takes minutes of practice to learn Move . Additionally, at the beginning of that practice, all of the Moves , , , must be already learned. Here, it is guaranteed that for each .
Takahashi has not learned any move at time . He cannot practice for more than one move simultaneously, nor can he stop a practice he has already started. Find the minimum number of minutes needed for Takahashi to learn Move .
Constraints
- , , , are all distinct.
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the minimum number of minutes needed for Takahashi to learn Move .
Sample Input 1
3
3 0
5 1 1
7 1 1
Sample Output 1
10
Here is one possible plan for Takahashi.
- At time , start practicing for Move to learn Move at time .
- Then, at time , start practicing for Move to learn Move at time .
Here, Takahashi spends minutes to learn Move , which is the fastest possible. Note that he does not need to learn Move to learn Move .
Sample Input 2
5
1000000000 0
1000000000 0
1000000000 0
1000000000 0
1000000000 4 1 2 3 4
Sample Output 2
5000000000
Note that the answer may not fit into a -bit integer.
update @ 2024/3/10 09:55:05