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, 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';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |