CF864E.Fire

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Polycarp is in really serious trouble — his house is on fire! It's time to save the most valuable items. Polycarp estimated that it would take tit_{i} seconds to save ii -th item. In addition, for each item, he estimated the value of did_{i} — the moment after which the item ii will be completely burned and will no longer be valuable for him at all. In particular, if ti>=dit_{i}>=d_{i} , then ii -th item cannot be saved.

Given the values pip_{i} for each of the items, find a set of items that Polycarp can save such that the total value of this items is maximum possible. Polycarp saves the items one after another. For example, if he takes item aa first, and then item bb , then the item aa will be saved in tat_{a} seconds, and the item bb — in ta+tbt_{a}+t_{b} seconds after fire started.

输入格式

The first line contains a single integer nn ( 1<=n<=1001<=n<=100 ) — the number of items in Polycarp's house.

Each of the following nn lines contains three integers ti,di,pit_{i},d_{i},p_{i} ( 1<=ti<=201<=t_{i}<=20 , 1<=di<=20001<=d_{i}<=2000 , 1<=pi<=201<=p_{i}<=20 ) — the time needed to save the item ii , the time after which the item ii will burn completely and the value of item ii .

输出格式

In the first line print the maximum possible total value of the set of saved items. In the second line print one integer mm — the number of items in the desired set. In the third line print mm distinct integers — numbers of the saved items in the order Polycarp saves them. Items are 1-indexed in the same order in which they appear in the input. If there are several answers, print any of them.

输入输出样例

  • 输入#1

    3
    3 7 4
    2 6 5
    3 7 6
    

    输出#1

    11
    2
    2 3 
    
  • 输入#2

    2
    5 6 1
    3 3 5
    

    输出#2

    1
    1
    1 
    

说明/提示

In the first example Polycarp will have time to save any two items, but in order to maximize the total value of the saved items, he must save the second and the third item. For example, he can firstly save the third item in 33 seconds, and then save the second item in another 22 seconds. Thus, the total value of the saved items will be 6+5=116+5=11 .

In the second example Polycarp can save only the first item, since even if he immediately starts saving the second item, he can save it in 33 seconds, but this item will already be completely burned by this time.

首页