别怕,DravDe 很善良AI (CI翻译)
A motorcade of $*n*$ trucks, driving from city «Z» to city «З», has approached a tunnel, known as Tunnel of Horror. Among truck drivers there were rumours about monster DravDe, who hunts for drivers in that tunnel. Some drivers fear to go first, others - to be the last, but let's consider the general case. Each truck is described with four numbers:
一列由 $*n*$ 辆卡车组成的车队正从城市 «Z» 驶向城市 «З»,此时车队来到了一条名为“恐怖隧道”的隧道前。卡车司机之间流传着关于怪物 DravDe 的传闻:它会在隧道里捕食司机。有些司机害怕第一个通过,有些司机害怕最后一个通过。下面考虑一般情况。每辆卡车由四个数描述:AI (CI翻译)
$*v*$— value of the truck, of its passangers and cargo$*c*$— amount of passanger on the truck, the driver included$*l*$— total amount of people that should go into the tunnel before this truck, so that the driver can overcome his fear («if the monster appears in front of the motorcade, he'll eat them first»)$*r*$— total amount of people that should follow this truck, so that the driver can overcome his fear («if the monster appears behind the motorcade, he'll eat them first»).
$*v*$— 卡车及其乘客和货物的价值$*c*$— 卡车上的乘客人数,包括司机$*l*$— 为了让司机克服恐惧,在这辆卡车之前必须进入隧道的总人数(“如果怪物出现在车队前方,它会先吃掉他们”)$*r*$— 为了让司机克服恐惧,在这辆卡车之后必须进入隧道的总人数(“如果怪物出现在车队后方,它会先吃掉他们”)
Since the road is narrow, it's impossible to escape DravDe, if he appears from one side. Moreover, the motorcade can't be rearranged. The order of the trucks can't be changed, but it's possible to take any truck out of the motorcade, and leave it near the tunnel for an indefinite period. You, as the head of the motorcade, should remove some of the trucks so, that the rest of the motorcade can move into the tunnel and the total amount of the left trucks' values is maximal.
由于道路狭窄,如果 DravDe 从一侧出现,就无法逃脱。此外,车队不能重新排列。卡车的顺序不能改变,但可以将任意卡车从车队中移出,并让它在隧道旁停留任意长的时间。作为车队负责人,你需要移走一些卡车,使剩余车队能够进入隧道,并使留下的卡车总价值最大。AI (CI翻译)
Input
输入格式
AI (CI翻译)The first input line contains integer number $*n*$ ($1 ≤ *n* ≤ 10^{5}$) — amount of trucks in the motorcade. The following $*n*$ lines contain four integers each. Numbers in the $*i*$-th line: $*v*_{*i*}, *c*_{*i*}, *l*_{*i*}, *r*_{*i*}$ ($1 ≤ *v*_{*i*} ≤ 10^{4}, 1 ≤ *c*_{*i*} ≤ 10^{5}, 0 ≤ *l*_{*i*}, *r*_{*i*} ≤ 10^{5}$) — describe the $*i*$-th truck. The trucks are numbered from 1, counting from the front of the motorcade.
输入的第一行包含整数 $*n*$($1 ≤ *n* ≤ 10^{5}$),表示车队中的卡车数量。接下来的 $*n*$ 行每行包含四个整数。第 $*i*$ 行中的数为 $*v*_{*i*}, *c*_{*i*}, *l*_{*i*}, *r*_{*i*}$($1 ≤ *v*_{*i*} ≤ 10^{4}, 1 ≤ *c*_{*i*} ≤ 10^{5}, 0 ≤ *l*_{*i*}, *r*_{*i*} ≤ 10^{5}$),描述第 $i$ 辆卡车。卡车按照从车队最前方开始的顺序编号,编号从 1 开始。AI (CI翻译)
Output
输出格式
AI (CI翻译)In the first line output number $*k*$ — amount of trucks that will drive into the tunnel. In the second line output $*k*$ numbers — indexes of these trucks in ascending order. Don't forget please that you are not allowed to change the order of trucks. If the answer is not unique, output any.
第一行输出整数 $*k*$,表示将驶入隧道的卡车数量。第二行输出 $*k*$ 个整数,表示这些卡车的编号,按升序排列。请注意,卡车的顺序不能改变。如果答案不唯一,输出任意一个。AI (CI翻译)
样例
5
1 1 0 3
1 1 1 2
1 1 2 1
1 1 3 0
2 1 3 0
4
1 2 3 5
5
1 1 0 3
10 1 2 1
2 2 1 1
10 1 1 2
3 1 3 0
3
1 3 5
题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。