#include "books.h"
#include<bits/stdc++.h>
using namespace std;
#define int long long
long long minimum_walk(std::vector<int32_t> p, int32_t s) {
// return 0;
int l = 0;
int r = (int) p.size()-1;
while(l < s && p[l] == l) l++;
while(r > s && p[r] == r) r--;
if(r > l) return 0;
// int n = p.size();
int ans = 0;
int max_reach = -1;
for(int i = l; i <= r; i++) {
ans+= abs(p[i]-i);
if(i != l && max_reach < i) ans+= 2;
max_reach = max(max_reach,(int) p[i]);
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
3rd lines differ - on the 1st token, expected: '6', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
3rd lines differ - on the 1st token, expected: '6', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
3rd lines differ - on the 1st token, expected: '6', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
3rd lines differ - on the 1st token, expected: '3304', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
3rd lines differ - on the 1st token, expected: '6', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |