이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |