http://codeforces.com/contest/585/problem/A
This question must be clear order of things happen, first of all deal with v [i], followed by subsequent order of crying children, in fact, is directly next traversal, while traversing the side of the handle, stacking cry value, with a queue but self-defeating
Worried that p [i] will be too small, use a long, sample 56 that all children are crying, and the result p [i] burst into positive
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 }