luogu#P4937. Portal1

Portal1

Background

There are many ways for an Agent to obtain resources, and HACK is one of them. By breaking into a Portal, you can get many useful resources.

Because the ENLIGHTENED headquarters joined the XM war, there are only a small amount of usable resources left. Therefore, the ENLIGHTENED operation commander wants to carry out HACK activities to increase the inventory as much as possible.

Problem Description

There are nn Portals on the map that can be HACKed, numbered from 11 to nn. HACKing Portal ii takes tit_i seconds and can produce cic_i resources to add to the inventory. However, only Portals with energy can produce resources when HACKed. For Portal ii, its energy will be completely depleted at time did_i seconds. ENLIGHTENED wants to know the maximum amount the inventory can be increased, and also output the indices of the Portals that need to be HACKed in increasing order.

Input Format

The first line contains an integer nn.

The next nn lines each contain three integers tit_i, did_i, cic_i.

Output Format

The first line outputs an integer: the maximum amount the inventory can be increased.

The second line outputs an integer: how many Portals need to be HACKed.

The third line outputs the indices of the Portals to be HACKed in increasing order. If there are multiple valid HACK plans, output any one of them.

3
5 6 5
1 8 2
2 7 3

7
2
1 2

Hint

For 20%20\% of the data, n5n\leq5, ti5t_i\leq 5, ci5c_i\leq 5, di10d_i\leq10.

For 40%40\% of the data, n20n\leq 20, ti10t_i\leq 10, ci10c_i\leq 10, di100d_i\leq 100.

For 60%60\% of the data, n50n\leq50, ti15t_i\leq15, ci15c_i\leq15, di1000d_i\leq1000.

For 100%100\% of the data, 1n1001\leq n\leq 100, 1ti201 \leq t_i \leq 20, 1ci201\leq c_i \leq 20, 1di20001 \leq d_i \leq 2000

Translated by ChatGPT 5