#include <bits/stdc++.h>
using namespace std;
struct node{
int pos, time, free, id;
bool operator < (const node& o) const{
if(time!=o.time) return time>o.time;
return pos<o.pos;
}
};
int n, m, ans[20005], cnt[305];
array<int, 3> arr[20005];
bool good[305];
priority_queue<node> pq;
int main(){
// freopen("a.in", "r", stdin);
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)
pq.push({1, arr[i][0], 0, i});
while(pq.size()){
auto [pos, time, free, id] = pq.top(); pq.pop(); cnt[pos]++;
if(pos==300){ans[id] = time; continue;}
if(free) pq.push({pos+1, time+1, free-1, id});
else if(!good[pos] || !(cnt[pos+1]%20)) pq.push({pos+1, time+arr[id][pos/100], 0, id});
else pq.push({pos+1, time+1, (cnt[pos+1]%20)-1, id});
}
for(int i = 0; i<n; ++i)
cout << ans[i] << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
7 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
7 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |