#include <bits/stdc++.h>
using namespace std;
struct node{int pos, free, id;};
int n, m, ans[20005], cnt[305];
array<int, 3> arr[20005];
bool good[305]; vector<node> mp[305*55];
int main(){
cin.tie(0)->sync_with_stdio(0);
cin >> n;
for(int i = 0; i<n; ++i)
cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
cin >> m;
for(int i = 0; i<m; ++i){
int a; cin >> a;
good[a] = 1;
} cnt[0] = n;
for(int i = 0; i<n; ++i)
mp[arr[i][0]].push_back({1, 0, i});
for(int t = 0; t<305*55; ++t){
vector<int> todo;
for(auto [pos, free, id]:mp[t]){
todo.push_back(pos);
if(pos==300) ans[id] = t;
else if(free) mp[t+1].push_back({pos+1, free-1, id});
else if(!good[pos] || !(cnt[pos]%20)) mp[t+arr[id][pos/100]].push_back({pos+1, 0, id});
else mp[t+1].push_back({pos+1, (cnt[pos]%20)-1, id});
}
for(auto x : todo) ++cnt[x];
}
for(int i = 0; i<n; ++i)
cout << ans[i] << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
716 KB |
Output is correct |
2 |
Correct |
5 ms |
1740 KB |
Output is correct |
3 |
Correct |
12 ms |
4812 KB |
Output is correct |
4 |
Correct |
36 ms |
15852 KB |
Output is correct |
5 |
Correct |
218 ms |
88740 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
716 KB |
Output is correct |
2 |
Correct |
1 ms |
716 KB |
Output is correct |
3 |
Correct |
1 ms |
716 KB |
Output is correct |
4 |
Correct |
1 ms |
716 KB |
Output is correct |
5 |
Correct |
2 ms |
844 KB |
Output is correct |
6 |
Correct |
1 ms |
972 KB |
Output is correct |
7 |
Correct |
4 ms |
1100 KB |
Output is correct |
8 |
Correct |
4 ms |
1612 KB |
Output is correct |
9 |
Correct |
4 ms |
1868 KB |
Output is correct |
10 |
Correct |
5 ms |
2220 KB |
Output is correct |
11 |
Correct |
3 ms |
1996 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
716 KB |
Output is correct |
2 |
Correct |
5 ms |
1740 KB |
Output is correct |
3 |
Correct |
12 ms |
4812 KB |
Output is correct |
4 |
Correct |
36 ms |
15852 KB |
Output is correct |
5 |
Correct |
218 ms |
88740 KB |
Output is correct |
6 |
Correct |
1 ms |
716 KB |
Output is correct |
7 |
Correct |
1 ms |
716 KB |
Output is correct |
8 |
Correct |
1 ms |
716 KB |
Output is correct |
9 |
Correct |
1 ms |
716 KB |
Output is correct |
10 |
Correct |
2 ms |
844 KB |
Output is correct |
11 |
Correct |
1 ms |
972 KB |
Output is correct |
12 |
Correct |
4 ms |
1100 KB |
Output is correct |
13 |
Correct |
4 ms |
1612 KB |
Output is correct |
14 |
Correct |
4 ms |
1868 KB |
Output is correct |
15 |
Correct |
5 ms |
2220 KB |
Output is correct |
16 |
Correct |
3 ms |
1996 KB |
Output is correct |
17 |
Correct |
14 ms |
5884 KB |
Output is correct |
18 |
Correct |
19 ms |
9612 KB |
Output is correct |
19 |
Correct |
74 ms |
37468 KB |
Output is correct |
20 |
Correct |
117 ms |
51596 KB |
Output is correct |
21 |
Correct |
124 ms |
60740 KB |
Output is correct |
22 |
Correct |
149 ms |
75588 KB |
Output is correct |
23 |
Correct |
136 ms |
72828 KB |
Output is correct |