#P16195. [ROIR 2014 Day 1] Olympiad 奥赛

    ID: 18122 远端评测题 2000ms 256MiB 尝试: 0 已通过: 0 显示难度普及 上传者: 标签>动态规划 DP2014离散化Special JudgeROIR(俄罗斯)

[ROIR 2014 Day 1] Olympiad 奥赛

Problem Description

In an inter-regional robot programming Olympiad, the contest has only one round and uses a special way to release problems. The problems are not given to contestants all at once; instead, they are released one by one in order. Problem ii (1in)(1 \le i \le n) becomes available at time sis_i minutes. Whenever a problem appears, the contestant must immediately decide whether to solve it. If they decide to solve it, they have tit_i minutes to submit an answer, and during this time they cannot switch to solve other problems. If they skip this problem, they can never come back to solve it later. After the time for the current solved problem runs out, the contestant can immediately start solving new problems that are available at that same moment (if any), or wait until the next problem appears. For each correctly solved problem, the contestant earns cic_i points.

Arthur represents a regional AI center in the contest. He knows that this contest tests not only problem-solving ability, but also strategy— which problems to solve and which to skip. Before the contest starts, all contestants know each problem’s release time, solving time, and score. Arthur is a genius and is guaranteed to finish and submit any problem he chooses within the given time.

Write a program to help Arthur compute the maximum score he can get, and which problems he should solve.

Input Format

The first line contains an integer nn (1n100000)(1 \le n \le 100\,000), the number of problems in the contest.

The next nn lines each contain three integers: sis_i (the release time of problem ii, in minutes), tit_i (the solving time, in minutes), and cic_i (the points earned for solving it). All numbers satisfy 1si,ti,ci1091 \le s_i, t_i, c_i \le 10^9.

Output Format

The first line output an integer: the maximum score Arthur can obtain.

The second line output an integer mm: the number of problems Arthur solves under an optimal strategy.

The third line output mm integers separated by spaces: the indices of these problems (starting from 11, numbered in the input order), in the order Arthur solves them.

If there are multiple optimal strategies, output any one of them.

2
1 1 1
2 2 2

3
2
1 2

3
1 2 1
3 2 1
2 4 3

3
1
3

Hint

In the first sample, Arthur can finish all problems and get 33 points.

In the second sample, solving the last problem gives 33 points, which is better than solving only the first two problems for 22 points.

Scoring

For the 3030-point testdata, all cic_i are the same and n1000n \le 1000.

For the 5050-point testdata, all cic_i are the same.

For the 5050-point testdata, n1000n \le 1000.

Translation source: GPT 4.1 mini.

Translated by ChatGPT 5