#include <iostream>
#include <algorithm>
#include "books.h"
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
int N,S;
ll P[1000006];
ll ans;
long long minimum_walk(std::vector<int> q, int s) {
N=q.size();
S=s;
for(ll i=0;i<N;i++){
P[i]=q[i];
ans+=abs(P[i]-i);
}
for(ll i=0;P[i]==i;i++)
ans+=2;
for(ll i=N-1;P[i]==i;i--)
ans-=2;
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
484 KB |
Output is correct |
3 |
Correct |
28 ms |
564 KB |
Output is correct |
4 |
Correct |
2 ms |
564 KB |
Output is correct |
5 |
Incorrect |
2 ms |
564 KB |
3rd lines differ - on the 1st token, expected: '4', found: '2' |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
484 KB |
Output is correct |
3 |
Correct |
28 ms |
564 KB |
Output is correct |
4 |
Correct |
2 ms |
564 KB |
Output is correct |
5 |
Incorrect |
2 ms |
564 KB |
3rd lines differ - on the 1st token, expected: '4', found: '2' |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
484 KB |
Output is correct |
3 |
Correct |
28 ms |
564 KB |
Output is correct |
4 |
Correct |
2 ms |
564 KB |
Output is correct |
5 |
Incorrect |
2 ms |
564 KB |
3rd lines differ - on the 1st token, expected: '4', found: '2' |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
676 KB |
3rd lines differ - on the 1st token, expected: '3304', found: '2744' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
484 KB |
Output is correct |
3 |
Correct |
28 ms |
564 KB |
Output is correct |
4 |
Correct |
2 ms |
564 KB |
Output is correct |
5 |
Incorrect |
2 ms |
564 KB |
3rd lines differ - on the 1st token, expected: '4', found: '2' |
6 |
Halted |
0 ms |
0 KB |
- |