This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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]);
sp = j;
}
}
for (int j = sp; j >= 1; j--){
if (a[j] > a[j-1]) {
swap(a[j], a[j - 1]);
}
}
if (sp == 0) break;
rs+= sp * 2;
}
return rs;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |