#include <bits/stdc++.h>
#define N 501
using namespace std;
typedef long long ll;
int n, s, ans[1000050];
ll minimum_walk(vector<int> v, int s_)
{
ll sum = 0, last = 0;
n = v.size(), s = s_;
for(int i = 0; i < n; i++)
{
while(v[i] != i)
{
swap(v[i], v[v[i]]);
sum += abs(v[v[i]] - v[i]);
last = min(v[i], v[v[i]]);
}
sum ++;
}
return sum + last - 1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
248 KB |
Output is correct |
2 |
Incorrect |
1 ms |
488 KB |
3rd lines differ - on the 1st token, expected: '6', found: '4' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
248 KB |
Output is correct |
2 |
Incorrect |
1 ms |
488 KB |
3rd lines differ - on the 1st token, expected: '6', found: '4' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
248 KB |
Output is correct |
2 |
Incorrect |
1 ms |
488 KB |
3rd lines differ - on the 1st token, expected: '6', found: '4' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
580 KB |
3rd lines differ - on the 1st token, expected: '3304', found: '3160' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
248 KB |
Output is correct |
2 |
Incorrect |
1 ms |
488 KB |
3rd lines differ - on the 1st token, expected: '6', found: '4' |
3 |
Halted |
0 ms |
0 KB |
- |