#include<bits/stdc++.h>
#define forf(i,a,b) for(int i = a; i<=b; i++)
#define forb(i,a,b) for(int i = a; i>=b; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
using namespace std;
int N,M;
int A[20001][3];
struct ST{
int id,time,acc;
bool operator<(const ST &r){
if(time ==r.time) return id<r.id;
return time<r.time;
}
};
vector<ST> dist[100001];
int isacc[100001];
int ans[20001];
int main(){
scanf("%d" ,&N);
forf(i,1,N){
scanf("%d %d %d" , &A[i][0],&A[i][1],&A[i][2]);
}
scanf("%d" , &M);
forf(i,1,M){
int t; scanf("%d" , &t);
isacc[t] = 1;
}
forf(i,1,N) dist[0].push_back({i,0,0});
forf(i,0,299){
int seg = i/100;
sort(all(dist[i]));
int cnt = 0;
forf(j,0,N-1){
if(j && dist[i][j-1].time == dist[i][j].time) cnt++;
else cnt = 0;
if(isacc[i] && dist[i][j].acc == 0) dist[i][j].acc = (j-cnt)%20;
if(dist[i][j].acc) dist[i+1].push_back({dist[i][j].id,dist[i][j].time+1,dist[i][j].acc-1});
else dist[i+1].push_back({dist[i][j].id,dist[i][j].time+A[dist[i][j].id][seg],0});
}
}
for(auto i : dist[300]){
ans[i.id] = i.time;
}
forf(i,1,N) printf("%d\n" , ans[i]);
}
Compilation message
segway.cpp: In function 'int main()':
segway.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
20 | scanf("%d" ,&N);
| ~~~~~^~~~~~~~~~
segway.cpp:22:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
22 | scanf("%d %d %d" , &A[i][0],&A[i][1],&A[i][2]);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
segway.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
24 | scanf("%d" , &M);
| ~~~~~^~~~~~~~~~~
segway.cpp:26:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
26 | int t; scanf("%d" , &t);
| ~~~~~^~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2904 KB |
Output is correct |
2 |
Correct |
4 ms |
4188 KB |
Output is correct |
3 |
Correct |
9 ms |
6492 KB |
Output is correct |
4 |
Correct |
40 ms |
14876 KB |
Output is correct |
5 |
Correct |
253 ms |
74984 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2904 KB |
Output is correct |
2 |
Correct |
1 ms |
2908 KB |
Output is correct |
3 |
Correct |
2 ms |
2908 KB |
Output is correct |
4 |
Correct |
1 ms |
2908 KB |
Output is correct |
5 |
Correct |
2 ms |
3164 KB |
Output is correct |
6 |
Correct |
2 ms |
3164 KB |
Output is correct |
7 |
Correct |
2 ms |
3420 KB |
Output is correct |
8 |
Correct |
3 ms |
3932 KB |
Output is correct |
9 |
Correct |
3 ms |
3932 KB |
Output is correct |
10 |
Correct |
5 ms |
4952 KB |
Output is correct |
11 |
Correct |
3 ms |
3756 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2904 KB |
Output is correct |
2 |
Correct |
4 ms |
4188 KB |
Output is correct |
3 |
Correct |
9 ms |
6492 KB |
Output is correct |
4 |
Correct |
40 ms |
14876 KB |
Output is correct |
5 |
Correct |
253 ms |
74984 KB |
Output is correct |
6 |
Correct |
1 ms |
2904 KB |
Output is correct |
7 |
Correct |
1 ms |
2908 KB |
Output is correct |
8 |
Correct |
2 ms |
2908 KB |
Output is correct |
9 |
Correct |
1 ms |
2908 KB |
Output is correct |
10 |
Correct |
2 ms |
3164 KB |
Output is correct |
11 |
Correct |
2 ms |
3164 KB |
Output is correct |
12 |
Correct |
2 ms |
3420 KB |
Output is correct |
13 |
Correct |
3 ms |
3932 KB |
Output is correct |
14 |
Correct |
3 ms |
3932 KB |
Output is correct |
15 |
Correct |
5 ms |
4952 KB |
Output is correct |
16 |
Correct |
3 ms |
3756 KB |
Output is correct |
17 |
Correct |
12 ms |
6492 KB |
Output is correct |
18 |
Correct |
23 ms |
10332 KB |
Output is correct |
19 |
Correct |
126 ms |
34908 KB |
Output is correct |
20 |
Correct |
158 ms |
43284 KB |
Output is correct |
21 |
Correct |
222 ms |
57876 KB |
Output is correct |
22 |
Correct |
282 ms |
75088 KB |
Output is correct |
23 |
Correct |
227 ms |
74836 KB |
Output is correct |