-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathmain.cpp
More file actions
84 lines (66 loc) · 1.41 KB
/
Copy pathmain.cpp
File metadata and controls
84 lines (66 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include <iostream>
#include <utility>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <list>
#include <map>
using namespace std;
struct Entry {
int v, d, p;
int index;
bool away;
};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<Entry> es;
vector<int> res;
for(int i = 0; i < n; i++) {
Entry e;
cin >> e.v >> e.d >> e.p;
e.index = i + 1;
e.away = false;
es.push_back(e);
}
for(int i = 0; i < n; ++i) {
if(es[i].away) continue;
res.push_back(es[i].index);
int delta_p = es[i].v;
vector<int> crazy_indices;
for(int j = i + 1; j < n; j++) {
if(es[j].away) continue;
if(es[j].p >= delta_p) {
es[j].p -= delta_p;
} else {
es[j].away = true;
crazy_indices.push_back(j);
}
delta_p -= 1;
if(delta_p <= 0)
break;
}
for(vector<int>::iterator cit = crazy_indices.begin(); cit != crazy_indices.end(); ++cit) {
int j = *cit;
int delta_p = es[j].d;
for(int k = j+1; k < n; k++) {
if(es[k].away) continue;
if(es[k].p >= delta_p) {
es[k].p -= delta_p;
} else {
es[k].away = true;
delta_p += es[k].d;
}
}
}
}
cout << res.size() << endl;
for(int i = 0; i < res.size(); i++) {
cout << res[i] << " ";
}
cout << endl;
return 0;
}