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 "books.h"
#include<bits/stdc++.h>
using namespace std;
long long minimum_walk(std::vector<int> p, int s) {
map<int,int>v;
int n=p.size();
long long int a(0);
int c(0);
for(int i=0;i<n;++i)
{
a+=abs(i-p[i]);
for(int j=min(i,p[i]);j<max(i,p[i]);++j)
v[j]=1;
}
for(int i=0;i<n-1;++i)
{
if(!v[i])
++c;
else
{
a+=2*c;
c=0;
}
}
return a;
}
# | 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... |