This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |