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 <iostream>
#include <algorithm>
#include "books.h"
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
int N,S;
ll P[1000006];
ll ans;
long long minimum_walk(std::vector<int> q, int s) {
N=q.size();
S=s;
for(ll i=0;i<N;i++){
P[i]=q[i];
ans+=abs(P[i]-i);
}
for(ll i=0;P[i]==i;i++)
ans+=2;
for(ll i=N-1;P[i]==i;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... |