#include "overtaking.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) begin(a),end(a)
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
const int mxN = (int)1010;
multiset<pair<ll,int>> S[mxN];
int l, n, m, x;
vector<pair<ll,int>> t;
vi s, w;
void init(int L, int N, vll T, vi W, int X, int M, vi S)
{
l = L, n = N, m = M, x = X; int i = 0;
for(auto u : T) t.pb({u,i}),i++;
for(auto u : S) s.pb(u);
for(auto u : W) w.pb(u);
w.pb(x);
}
ll arrival_time(ll Y){
S[0].clear();
for(auto cur : t)
S[0].insert({cur.first,cur.second});
S[0].insert({Y,n});
for(int i = 0; i < m-1; i++){
S[i+1].clear();
ll dis = s[i+1]-s[i], mx = 0, mx2 = 0, mxu = -1, pre=-1;
for(auto cur : S[i]){
auto u = cur.first;
auto ind = cur.second;
auto speed = w[ind];
if(u!=pre) mx = max(mx, mx2);
pre = u;
S[i+1].insert({max(u+dis*speed,mx),ind});
mx2 = max(mx2, u+dis*speed);
}
}
for(auto cur : S[m-1])
if(cur.second==n) return cur.first;
return -1;
}
Compilation message
overtaking.cpp: In function 'll arrival_time(ll)':
overtaking.cpp:33:48: warning: unused variable 'mxu' [-Wunused-variable]
33 | ll dis = s[i+1]-s[i], mx = 0, mx2 = 0, mxu = -1, pre=-1;
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
5 ms |
348 KB |
Output is correct |
6 |
Correct |
18 ms |
568 KB |
Output is correct |
7 |
Correct |
36 ms |
604 KB |
Output is correct |
8 |
Correct |
44 ms |
636 KB |
Output is correct |
9 |
Correct |
45 ms |
604 KB |
Output is correct |
10 |
Correct |
43 ms |
628 KB |
Output is correct |
11 |
Correct |
46 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
596 KB |
Output is correct |
2 |
Correct |
2 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
9 ms |
344 KB |
Output is correct |
5 |
Correct |
53 ms |
556 KB |
Output is correct |
6 |
Correct |
133 ms |
632 KB |
Output is correct |
7 |
Correct |
170 ms |
660 KB |
Output is correct |
8 |
Correct |
190 ms |
660 KB |
Output is correct |
9 |
Correct |
169 ms |
604 KB |
Output is correct |
10 |
Correct |
167 ms |
644 KB |
Output is correct |
11 |
Correct |
184 ms |
640 KB |
Output is correct |
12 |
Correct |
193 ms |
600 KB |
Output is correct |
13 |
Correct |
167 ms |
652 KB |
Output is correct |
14 |
Correct |
170 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
596 KB |
Output is correct |
7 |
Correct |
2 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
42 ms |
1112 KB |
Output is correct |
10 |
Correct |
43 ms |
1112 KB |
Output is correct |
11 |
Correct |
43 ms |
1112 KB |
Output is correct |
12 |
Correct |
42 ms |
1116 KB |
Output is correct |
13 |
Correct |
43 ms |
860 KB |
Output is correct |
14 |
Correct |
44 ms |
1116 KB |
Output is correct |
15 |
Correct |
45 ms |
856 KB |
Output is correct |
16 |
Correct |
45 ms |
1116 KB |
Output is correct |
17 |
Correct |
43 ms |
1112 KB |
Output is correct |
18 |
Correct |
49 ms |
1096 KB |
Output is correct |
19 |
Correct |
44 ms |
1124 KB |
Output is correct |
20 |
Correct |
45 ms |
860 KB |
Output is correct |
21 |
Correct |
21 ms |
600 KB |
Output is correct |
22 |
Correct |
27 ms |
604 KB |
Output is correct |
23 |
Correct |
37 ms |
860 KB |
Output is correct |
24 |
Correct |
38 ms |
860 KB |
Output is correct |
25 |
Correct |
36 ms |
860 KB |
Output is correct |
26 |
Correct |
38 ms |
1056 KB |
Output is correct |
27 |
Correct |
38 ms |
860 KB |
Output is correct |
28 |
Correct |
28 ms |
740 KB |
Output is correct |
29 |
Correct |
32 ms |
860 KB |
Output is correct |
30 |
Correct |
29 ms |
860 KB |
Output is correct |
31 |
Correct |
30 ms |
860 KB |
Output is correct |
32 |
Correct |
55 ms |
1112 KB |
Output is correct |
33 |
Correct |
43 ms |
1116 KB |
Output is correct |
34 |
Correct |
45 ms |
1116 KB |
Output is correct |
35 |
Correct |
53 ms |
1116 KB |
Output is correct |
36 |
Correct |
43 ms |
860 KB |
Output is correct |
37 |
Correct |
44 ms |
860 KB |
Output is correct |
38 |
Correct |
57 ms |
1116 KB |
Output is correct |
39 |
Correct |
53 ms |
1112 KB |
Output is correct |
40 |
Correct |
50 ms |
1140 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
5 ms |
348 KB |
Output is correct |
7 |
Correct |
18 ms |
568 KB |
Output is correct |
8 |
Correct |
36 ms |
604 KB |
Output is correct |
9 |
Correct |
44 ms |
636 KB |
Output is correct |
10 |
Correct |
45 ms |
604 KB |
Output is correct |
11 |
Correct |
43 ms |
628 KB |
Output is correct |
12 |
Correct |
46 ms |
604 KB |
Output is correct |
13 |
Correct |
1 ms |
596 KB |
Output is correct |
14 |
Correct |
2 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
42 ms |
1112 KB |
Output is correct |
17 |
Correct |
43 ms |
1112 KB |
Output is correct |
18 |
Correct |
43 ms |
1112 KB |
Output is correct |
19 |
Correct |
42 ms |
1116 KB |
Output is correct |
20 |
Correct |
43 ms |
860 KB |
Output is correct |
21 |
Correct |
44 ms |
1116 KB |
Output is correct |
22 |
Correct |
45 ms |
856 KB |
Output is correct |
23 |
Correct |
45 ms |
1116 KB |
Output is correct |
24 |
Correct |
43 ms |
1112 KB |
Output is correct |
25 |
Correct |
49 ms |
1096 KB |
Output is correct |
26 |
Correct |
44 ms |
1124 KB |
Output is correct |
27 |
Correct |
45 ms |
860 KB |
Output is correct |
28 |
Correct |
21 ms |
600 KB |
Output is correct |
29 |
Correct |
27 ms |
604 KB |
Output is correct |
30 |
Correct |
37 ms |
860 KB |
Output is correct |
31 |
Correct |
38 ms |
860 KB |
Output is correct |
32 |
Correct |
36 ms |
860 KB |
Output is correct |
33 |
Correct |
38 ms |
1056 KB |
Output is correct |
34 |
Correct |
38 ms |
860 KB |
Output is correct |
35 |
Correct |
28 ms |
740 KB |
Output is correct |
36 |
Correct |
32 ms |
860 KB |
Output is correct |
37 |
Correct |
29 ms |
860 KB |
Output is correct |
38 |
Correct |
30 ms |
860 KB |
Output is correct |
39 |
Correct |
55 ms |
1112 KB |
Output is correct |
40 |
Correct |
43 ms |
1116 KB |
Output is correct |
41 |
Correct |
45 ms |
1116 KB |
Output is correct |
42 |
Correct |
53 ms |
1116 KB |
Output is correct |
43 |
Correct |
43 ms |
860 KB |
Output is correct |
44 |
Correct |
44 ms |
860 KB |
Output is correct |
45 |
Correct |
57 ms |
1116 KB |
Output is correct |
46 |
Correct |
53 ms |
1112 KB |
Output is correct |
47 |
Correct |
50 ms |
1140 KB |
Output is correct |
48 |
Execution timed out |
3524 ms |
63056 KB |
Time limit exceeded |
49 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
5 ms |
348 KB |
Output is correct |
7 |
Correct |
18 ms |
568 KB |
Output is correct |
8 |
Correct |
36 ms |
604 KB |
Output is correct |
9 |
Correct |
44 ms |
636 KB |
Output is correct |
10 |
Correct |
45 ms |
604 KB |
Output is correct |
11 |
Correct |
43 ms |
628 KB |
Output is correct |
12 |
Correct |
46 ms |
604 KB |
Output is correct |
13 |
Correct |
1 ms |
596 KB |
Output is correct |
14 |
Correct |
2 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
9 ms |
344 KB |
Output is correct |
17 |
Correct |
53 ms |
556 KB |
Output is correct |
18 |
Correct |
133 ms |
632 KB |
Output is correct |
19 |
Correct |
170 ms |
660 KB |
Output is correct |
20 |
Correct |
190 ms |
660 KB |
Output is correct |
21 |
Correct |
169 ms |
604 KB |
Output is correct |
22 |
Correct |
167 ms |
644 KB |
Output is correct |
23 |
Correct |
184 ms |
640 KB |
Output is correct |
24 |
Correct |
193 ms |
600 KB |
Output is correct |
25 |
Correct |
167 ms |
652 KB |
Output is correct |
26 |
Correct |
170 ms |
604 KB |
Output is correct |
27 |
Correct |
42 ms |
1112 KB |
Output is correct |
28 |
Correct |
43 ms |
1112 KB |
Output is correct |
29 |
Correct |
43 ms |
1112 KB |
Output is correct |
30 |
Correct |
42 ms |
1116 KB |
Output is correct |
31 |
Correct |
43 ms |
860 KB |
Output is correct |
32 |
Correct |
44 ms |
1116 KB |
Output is correct |
33 |
Correct |
45 ms |
856 KB |
Output is correct |
34 |
Correct |
45 ms |
1116 KB |
Output is correct |
35 |
Correct |
43 ms |
1112 KB |
Output is correct |
36 |
Correct |
49 ms |
1096 KB |
Output is correct |
37 |
Correct |
44 ms |
1124 KB |
Output is correct |
38 |
Correct |
45 ms |
860 KB |
Output is correct |
39 |
Correct |
21 ms |
600 KB |
Output is correct |
40 |
Correct |
27 ms |
604 KB |
Output is correct |
41 |
Correct |
37 ms |
860 KB |
Output is correct |
42 |
Correct |
38 ms |
860 KB |
Output is correct |
43 |
Correct |
36 ms |
860 KB |
Output is correct |
44 |
Correct |
38 ms |
1056 KB |
Output is correct |
45 |
Correct |
38 ms |
860 KB |
Output is correct |
46 |
Correct |
28 ms |
740 KB |
Output is correct |
47 |
Correct |
32 ms |
860 KB |
Output is correct |
48 |
Correct |
29 ms |
860 KB |
Output is correct |
49 |
Correct |
30 ms |
860 KB |
Output is correct |
50 |
Correct |
55 ms |
1112 KB |
Output is correct |
51 |
Correct |
43 ms |
1116 KB |
Output is correct |
52 |
Correct |
45 ms |
1116 KB |
Output is correct |
53 |
Correct |
53 ms |
1116 KB |
Output is correct |
54 |
Correct |
43 ms |
860 KB |
Output is correct |
55 |
Correct |
44 ms |
860 KB |
Output is correct |
56 |
Correct |
57 ms |
1116 KB |
Output is correct |
57 |
Correct |
53 ms |
1112 KB |
Output is correct |
58 |
Correct |
50 ms |
1140 KB |
Output is correct |
59 |
Execution timed out |
3524 ms |
63056 KB |
Time limit exceeded |
60 |
Halted |
0 ms |
0 KB |
- |