#include <bits/stdc++.h>
#include "books.h"
using namespace std;
typedef long long int64;
int64 minimum_walk(vector<int> a, int s) {
int n = a.size();
int64 rs = 0;
for (int i = 0; i < n; i++){
int sp = 0;
for (int j = 0; j < n - i - 1; j++){
if (a[j] > a[j + 1]) {
swap(a[j], a[j + 1]);
rs++;
sp = j;
}
}
for (int j = sp; j >= 1; j--){
if (a[j] < a[j-1]) {
swap(a[j], a[j - 1]);
rs++;
}
}
if (sp == 0) break;
rs+= sp * 2;
}
return rs;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
3rd lines differ - on the 1st token, expected: '6', found: '7' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
3rd lines differ - on the 1st token, expected: '6', found: '7' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
3rd lines differ - on the 1st token, expected: '6', found: '7' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
3rd lines differ - on the 1st token, expected: '3304', found: '8368' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
3rd lines differ - on the 1st token, expected: '6', found: '7' |
3 |
Halted |
0 ms |
0 KB |
- |