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<iostream>
#include<algorithm>
using namespace std;
#define forn(i, n) for(int i=0; i<(int)n; ++i)
#define forsn(i, s, n) for(int i=s; i<(int)n; ++i)
const int MAXN=20010;
int n, m, speed[MAXN][3], tm[MAXN], sec[MAXN], cn[MAXN], ac[310], ord[MAXN];
int dist(int l, int r, int player){
int ret=0;
forn(i, 2){
int pos=100*(i+1);
if(l<pos && pos<r){
ret+=(pos-l)*speed[player][i];
l=pos;
}
}
int ind=l/100;
ret+=(r-l)*speed[player][ind];
return ret;
}
int main(){
scanf("%d", &n);
forn(i, n) forn(j, 3) scanf("%d", &speed[i][j]);
forn(i, n) ord[i]=i;
scanf("%d", &m);
forn(i, m) scanf("%d", ac+i);
ac[m++]=300;
int cur=0;
forn(i, m){
int dis=ac[i]-cur;
sort(ord, ord+n, [](int a, int b){
return tm[a]<tm[b];
});
int lst;
forn(j, n){
if(j==0 || tm[ord[j]]>tm[ord[j-1]]) lst=j;
cn[ord[j]]=lst;
}
forn(j, n){
if(sec[j]==0) sec[j]=cn[j]%20;
if(sec[j]>=dis){
sec[j]-=dis;
tm[j]+=dis;
}
else{
int pos=cur+sec[j];
tm[j]+=(sec[j]+dist(pos, ac[i], j));
sec[j]=0;
}
}
cur=ac[i];
}
forn(i, n) printf("%d\n", tm[i]);
}
Compilation message (stderr)
segway.cpp: In function 'int main()':
segway.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
25 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
segway.cpp:26:32: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
26 | forn(i, n) forn(j, 3) scanf("%d", &speed[i][j]);
| ~~~~~^~~~~~~~~~~~~~~~~~~~
segway.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
28 | scanf("%d", &m);
| ~~~~~^~~~~~~~~~
segway.cpp:29:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
29 | forn(i, m) scanf("%d", ac+i);
| ~~~~~^~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |