#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
716 KB |
Output is correct |
2 |
Correct |
4 ms |
1100 KB |
Output is correct |
3 |
Correct |
10 ms |
2196 KB |
Output is correct |
4 |
Correct |
34 ms |
5948 KB |
Output is correct |
5 |
Correct |
256 ms |
32820 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
716 KB |
Output is correct |
2 |
Correct |
1 ms |
716 KB |
Output is correct |
3 |
Correct |
1 ms |
716 KB |
Output is correct |
4 |
Correct |
1 ms |
716 KB |
Output is correct |
5 |
Correct |
2 ms |
716 KB |
Output is correct |
6 |
Correct |
1 ms |
716 KB |
Output is correct |
7 |
Correct |
2 ms |
844 KB |
Output is correct |
8 |
Correct |
3 ms |
972 KB |
Output is correct |
9 |
Correct |
3 ms |
1072 KB |
Output is correct |
10 |
Correct |
5 ms |
1168 KB |
Output is correct |
11 |
Correct |
3 ms |
1100 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
716 KB |
Output is correct |
2 |
Correct |
4 ms |
1100 KB |
Output is correct |
3 |
Correct |
10 ms |
2196 KB |
Output is correct |
4 |
Correct |
34 ms |
5948 KB |
Output is correct |
5 |
Correct |
256 ms |
32820 KB |
Output is correct |
6 |
Correct |
1 ms |
716 KB |
Output is correct |
7 |
Correct |
1 ms |
716 KB |
Output is correct |
8 |
Correct |
1 ms |
716 KB |
Output is correct |
9 |
Correct |
1 ms |
716 KB |
Output is correct |
10 |
Correct |
2 ms |
716 KB |
Output is correct |
11 |
Correct |
1 ms |
716 KB |
Output is correct |
12 |
Correct |
2 ms |
844 KB |
Output is correct |
13 |
Correct |
3 ms |
972 KB |
Output is correct |
14 |
Correct |
3 ms |
1072 KB |
Output is correct |
15 |
Correct |
5 ms |
1168 KB |
Output is correct |
16 |
Correct |
3 ms |
1100 KB |
Output is correct |
17 |
Correct |
13 ms |
2536 KB |
Output is correct |
18 |
Correct |
16 ms |
4180 KB |
Output is correct |
19 |
Correct |
81 ms |
14700 KB |
Output is correct |
20 |
Correct |
129 ms |
19700 KB |
Output is correct |
21 |
Correct |
138 ms |
23360 KB |
Output is correct |
22 |
Correct |
172 ms |
28048 KB |
Output is correct |
23 |
Correct |
147 ms |
25900 KB |
Output is correct |