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>
#define all(s) s.begin(),s.end()
using namespace std;
typedef int ll;
ll n,m,x,ans[20009],id[20009],a[20009][3],op[20009],p[309];
bool b[309];
vector<vector<ll> >v;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
v.resize(15009);
cin>>n;
for(ll i=0; i<n; i++)
for(ll j=0; j<3; j++)
cin>>a[i][j];
cin>>m;
for(ll i=0; i<m; i++)
{
cin>>x;
b[x]=1;
}
for(ll i=0; i<n; i++)
v[a[i][0]].push_back(i);
for(ll i=1; i<=15000; i++)
{
for(auto z:v[i])
{
id[z]++;
if(b[id[z]]&&op[z]==0)
op[z]=p[id[z]]%20;
if(id[z]==300)
{
if(ans[z]==0)
ans[z]=i;
}
else
{
if(op[z])
op[z]--,v[i+1].push_back(z);
else
v[i+a[z][id[z]/100]].push_back(z);
}
}
for(auto z:v[i])
p[id[z]]++;
}
for(ll i=0; i<n; i++)
cout<<ans[i]<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |