# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
243502 | vanic | Segway (COI19_segway) | C++14 | 279 ms | 32760 KiB |
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 <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
using namespace std;
const int maxn=2e4+5, maxp=305;
int v[maxn][3];
vector < int > q[50*maxp];
int loc[maxn];
int sad[maxp];
int acel[maxn];
bitset < maxp > boost;
int sol[maxn];
vector < int > ind;
int pref[maxp];
int main(){
int n;
scanf("%d", &n);
for(int i=0; i<n; i++){
scanf("%d%d%d", &v[i][0], &v[i][1], &v[i][2]);
q[v[i][0]].push_back(i);
}
int m;
scanf("%d", &m);
int a;
for(int i=0; i<m; i++){
scanf("%d", &a);
boost[a]=1;
}
for(int i=0; i<maxp; i++){
pref[i]=n;
}
int p;
for(int i=0; i<50*maxp; i++){
while(!q[i].empty()){
p=q[i].back();
q[i].pop_back();
ind.push_back(p);
pref[loc[p]]--;
loc[p]++;
sad[loc[p]]++;
if(loc[p]==300){
sol[p]=i;
continue;
}
if(!acel[p] && boost[loc[p]]){
acel[p]=(n-pref[loc[p]-1]-sad[loc[p]])%20;
}
if(acel[p]){
acel[p]--;
q[i+1].push_back(p);
}
else{
q[i+v[p][loc[p]/100]].push_back(p);
}
}
while(!ind.empty()){
sad[loc[ind.back()]]--;
ind.pop_back();
}
}
for(int i=0; i<n; i++){
printf("%d\n", sol[i]);
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |