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;
using ll =long long;
int minimum_walk(vector<int>p, int s){
int n=p.size();
ll ans=0;
for(int i=0;i<n;i++){
ans+=abs(p[i]-i);
}
int r=n-1;
while(r>=0&&p[r]==r)r--;
int ma=0;
for(int i=0;i<r;i++){
ma=max(ma,p[i]);
if(ma>i)ans+=2;
}
return ans;
}
# | 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... |