#include "books.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (1LL << 55)
#define MOD (1000 * 1000 * 1000 + 7)
#define maxn 1001111
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
int pre[maxn];
long long minimum_walk(vector<int> p, int s){
int n = p.size();
ll ans = 0;
for(int i = 0; i < n; i++){
ans += abs(p[i] - i);
int l = min(i, p[i]);
int d = max(i, p[i]);
pre[l]++;
pre[d]--;
}
for(int i = 1; i < n; i++)
pre[i] += pre[i - 1];
int last = -1;
for(int i = n - 1; i >= 0; i--){
if(pre[i] > 0){
last = i;
break;
}
}
for(int i = 0; i <= last; i++){
if(pre[i] == 0)
ans += 2;
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
360 KB |
Output is correct |
3 |
Correct |
3 ms |
472 KB |
Output is correct |
4 |
Correct |
3 ms |
712 KB |
Output is correct |
5 |
Correct |
2 ms |
712 KB |
Output is correct |
6 |
Correct |
2 ms |
712 KB |
Output is correct |
7 |
Correct |
2 ms |
712 KB |
Output is correct |
8 |
Correct |
2 ms |
712 KB |
Output is correct |
9 |
Correct |
3 ms |
712 KB |
Output is correct |
10 |
Correct |
2 ms |
712 KB |
Output is correct |
11 |
Correct |
3 ms |
756 KB |
Output is correct |
12 |
Correct |
3 ms |
756 KB |
Output is correct |
13 |
Correct |
3 ms |
756 KB |
Output is correct |
14 |
Correct |
2 ms |
760 KB |
Output is correct |
15 |
Correct |
3 ms |
760 KB |
Output is correct |
16 |
Correct |
3 ms |
760 KB |
Output is correct |
17 |
Correct |
3 ms |
760 KB |
Output is correct |
18 |
Correct |
3 ms |
760 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
360 KB |
Output is correct |
3 |
Correct |
3 ms |
472 KB |
Output is correct |
4 |
Correct |
3 ms |
712 KB |
Output is correct |
5 |
Correct |
2 ms |
712 KB |
Output is correct |
6 |
Correct |
2 ms |
712 KB |
Output is correct |
7 |
Correct |
2 ms |
712 KB |
Output is correct |
8 |
Correct |
2 ms |
712 KB |
Output is correct |
9 |
Correct |
3 ms |
712 KB |
Output is correct |
10 |
Correct |
2 ms |
712 KB |
Output is correct |
11 |
Correct |
3 ms |
756 KB |
Output is correct |
12 |
Correct |
3 ms |
756 KB |
Output is correct |
13 |
Correct |
3 ms |
756 KB |
Output is correct |
14 |
Correct |
2 ms |
760 KB |
Output is correct |
15 |
Correct |
3 ms |
760 KB |
Output is correct |
16 |
Correct |
3 ms |
760 KB |
Output is correct |
17 |
Correct |
3 ms |
760 KB |
Output is correct |
18 |
Correct |
3 ms |
760 KB |
Output is correct |
19 |
Correct |
2 ms |
788 KB |
Output is correct |
20 |
Correct |
3 ms |
792 KB |
Output is correct |
21 |
Correct |
3 ms |
796 KB |
Output is correct |
22 |
Correct |
3 ms |
796 KB |
Output is correct |
23 |
Correct |
3 ms |
804 KB |
Output is correct |
24 |
Correct |
3 ms |
932 KB |
Output is correct |
25 |
Correct |
4 ms |
932 KB |
Output is correct |
26 |
Correct |
3 ms |
932 KB |
Output is correct |
27 |
Correct |
3 ms |
932 KB |
Output is correct |
28 |
Correct |
3 ms |
932 KB |
Output is correct |
29 |
Correct |
4 ms |
932 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
360 KB |
Output is correct |
3 |
Correct |
3 ms |
472 KB |
Output is correct |
4 |
Correct |
3 ms |
712 KB |
Output is correct |
5 |
Correct |
2 ms |
712 KB |
Output is correct |
6 |
Correct |
2 ms |
712 KB |
Output is correct |
7 |
Correct |
2 ms |
712 KB |
Output is correct |
8 |
Correct |
2 ms |
712 KB |
Output is correct |
9 |
Correct |
3 ms |
712 KB |
Output is correct |
10 |
Correct |
2 ms |
712 KB |
Output is correct |
11 |
Correct |
3 ms |
756 KB |
Output is correct |
12 |
Correct |
3 ms |
756 KB |
Output is correct |
13 |
Correct |
3 ms |
756 KB |
Output is correct |
14 |
Correct |
2 ms |
760 KB |
Output is correct |
15 |
Correct |
3 ms |
760 KB |
Output is correct |
16 |
Correct |
3 ms |
760 KB |
Output is correct |
17 |
Correct |
3 ms |
760 KB |
Output is correct |
18 |
Correct |
3 ms |
760 KB |
Output is correct |
19 |
Correct |
2 ms |
788 KB |
Output is correct |
20 |
Correct |
3 ms |
792 KB |
Output is correct |
21 |
Correct |
3 ms |
796 KB |
Output is correct |
22 |
Correct |
3 ms |
796 KB |
Output is correct |
23 |
Correct |
3 ms |
804 KB |
Output is correct |
24 |
Correct |
3 ms |
932 KB |
Output is correct |
25 |
Correct |
4 ms |
932 KB |
Output is correct |
26 |
Correct |
3 ms |
932 KB |
Output is correct |
27 |
Correct |
3 ms |
932 KB |
Output is correct |
28 |
Correct |
3 ms |
932 KB |
Output is correct |
29 |
Correct |
4 ms |
932 KB |
Output is correct |
30 |
Correct |
235 ms |
19208 KB |
Output is correct |
31 |
Correct |
206 ms |
25992 KB |
Output is correct |
32 |
Correct |
177 ms |
32700 KB |
Output is correct |
33 |
Correct |
208 ms |
39512 KB |
Output is correct |
34 |
Correct |
220 ms |
46256 KB |
Output is correct |
35 |
Correct |
213 ms |
53128 KB |
Output is correct |
36 |
Correct |
229 ms |
59744 KB |
Output is correct |
37 |
Correct |
197 ms |
66504 KB |
Output is correct |
38 |
Correct |
181 ms |
73232 KB |
Output is correct |
39 |
Correct |
185 ms |
79936 KB |
Output is correct |
40 |
Correct |
202 ms |
86736 KB |
Output is correct |
41 |
Correct |
233 ms |
93480 KB |
Output is correct |
42 |
Correct |
238 ms |
100208 KB |
Output is correct |
43 |
Correct |
188 ms |
106952 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
106952 KB |
3rd lines differ - on the 1st token, expected: '3304', found: '2744' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
360 KB |
Output is correct |
3 |
Correct |
3 ms |
472 KB |
Output is correct |
4 |
Correct |
3 ms |
712 KB |
Output is correct |
5 |
Correct |
2 ms |
712 KB |
Output is correct |
6 |
Correct |
2 ms |
712 KB |
Output is correct |
7 |
Correct |
2 ms |
712 KB |
Output is correct |
8 |
Correct |
2 ms |
712 KB |
Output is correct |
9 |
Correct |
3 ms |
712 KB |
Output is correct |
10 |
Correct |
2 ms |
712 KB |
Output is correct |
11 |
Correct |
3 ms |
756 KB |
Output is correct |
12 |
Correct |
3 ms |
756 KB |
Output is correct |
13 |
Correct |
3 ms |
756 KB |
Output is correct |
14 |
Correct |
2 ms |
760 KB |
Output is correct |
15 |
Correct |
3 ms |
760 KB |
Output is correct |
16 |
Correct |
3 ms |
760 KB |
Output is correct |
17 |
Correct |
3 ms |
760 KB |
Output is correct |
18 |
Correct |
3 ms |
760 KB |
Output is correct |
19 |
Correct |
2 ms |
788 KB |
Output is correct |
20 |
Correct |
3 ms |
792 KB |
Output is correct |
21 |
Correct |
3 ms |
796 KB |
Output is correct |
22 |
Correct |
3 ms |
796 KB |
Output is correct |
23 |
Correct |
3 ms |
804 KB |
Output is correct |
24 |
Correct |
3 ms |
932 KB |
Output is correct |
25 |
Correct |
4 ms |
932 KB |
Output is correct |
26 |
Correct |
3 ms |
932 KB |
Output is correct |
27 |
Correct |
3 ms |
932 KB |
Output is correct |
28 |
Correct |
3 ms |
932 KB |
Output is correct |
29 |
Correct |
4 ms |
932 KB |
Output is correct |
30 |
Correct |
235 ms |
19208 KB |
Output is correct |
31 |
Correct |
206 ms |
25992 KB |
Output is correct |
32 |
Correct |
177 ms |
32700 KB |
Output is correct |
33 |
Correct |
208 ms |
39512 KB |
Output is correct |
34 |
Correct |
220 ms |
46256 KB |
Output is correct |
35 |
Correct |
213 ms |
53128 KB |
Output is correct |
36 |
Correct |
229 ms |
59744 KB |
Output is correct |
37 |
Correct |
197 ms |
66504 KB |
Output is correct |
38 |
Correct |
181 ms |
73232 KB |
Output is correct |
39 |
Correct |
185 ms |
79936 KB |
Output is correct |
40 |
Correct |
202 ms |
86736 KB |
Output is correct |
41 |
Correct |
233 ms |
93480 KB |
Output is correct |
42 |
Correct |
238 ms |
100208 KB |
Output is correct |
43 |
Correct |
188 ms |
106952 KB |
Output is correct |
44 |
Incorrect |
3 ms |
106952 KB |
3rd lines differ - on the 1st token, expected: '3304', found: '2744' |
45 |
Halted |
0 ms |
0 KB |
- |