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;
long long minimum_walk(vector<int> a,int s){
int n=a.size();
while(a[n-1]==n-1)n--;
long long ans=0;
for(int i=0;i<n;i++)ans+=abs(i-a[i]);
int pivot=0;
for(int i=0;i<n-1;i++){
pivot=max(pivot,a[i]);
if(i==pivot)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... |