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>
using namespace std;
#define for2(a,b,c) for(int a = b; a < c; a++)
#include "books.h"
#define ll long long
long long minimum_walk(std::vector<int> p, int s) {
if(s != 0) return 0;
ll res = 0;
int n = p.size();
for2(i,0,n) res += abs(i-p[i]);
int r = 0;
while(n > 0){
if(p[n-1] == n-1) n--;
else break;
}
for2(i,0,n-1){
r = max(r,p[i]);
if(i == r) res += 2;
}
return res;
}
# | 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... |