#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
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);
| ~~~~~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
316 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
456 KB |
Output is correct |
5 |
Correct |
15 ms |
1108 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
316 KB |
Output is correct |
2 |
Correct |
1 ms |
316 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
316 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
456 KB |
Output is correct |
5 |
Correct |
15 ms |
1108 KB |
Output is correct |
6 |
Correct |
1 ms |
316 KB |
Output is correct |
7 |
Correct |
1 ms |
316 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
2 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
12 ms |
396 KB |
Output is correct |
19 |
Correct |
25 ms |
632 KB |
Output is correct |
20 |
Correct |
9 ms |
724 KB |
Output is correct |
21 |
Correct |
49 ms |
852 KB |
Output is correct |
22 |
Correct |
97 ms |
984 KB |
Output is correct |
23 |
Correct |
119 ms |
992 KB |
Output is correct |