http://codeforces.com/contest/585/problem/A
这道题必须明确事情发生的顺序,首先处理v[i],其次是顺序往后的哭泣的小孩,其实是可以直接往后遍历,一边遍历一边处理,叠加cry值,用队列反而弄巧成拙了
担心p[i]会过小,要用long,样例56就是所有小孩都哭泣了,结果p[i]爆成正的
1 static final int maxn = 4100;
2 static int n;
3 static int[] v = new int[maxn], d = new int[maxn];
4 static long[] p = new long[maxn];
5 static ArrayList<Integer> ans = new ArrayList<>();
6
7 public static void main(String[] args) {
8 IO io = new IO();
9 n = io.nextInt();
10
11 for (int i = 0; i < n; i++) {
12 v[i] = io.nextInt();
13 d[i] = io.nextInt();
14 p[i] = io.nextInt();
15 }
16
17 for (int i = 0; i < n; i++)
18 if (p[i] >= 0) {
19 ans.add(i);
20
21 long cry = 0;
22 for (int j = i + 1; j < n; j++) {
23 if (p[j] < 0) continue;
24 if ((p[j] -= v[i] + cry) < 0) cry += d[j];
25 if (v[i] > 0) v[i]--;
26 }
27 }
28
29 io.println(ans.size());
30 for (int a : ans) io.print((a + 1) + " ");
31 io.println("");
32 }