# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
428053 | inwbear | Ancient Books (IOI17_books) | C++14 | 169 ms | 14844 KiB |
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;
set<pair<int,int> >ss;
long long ans=0;
long long minimum_walk(std::vector<int> p, int s)
{
int ed=0,rr=0,sw=0;
for(int i=0;i<p.size();i++)
{
if(p[i]!=i)sw=max(sw,max(i,p[i]));
}
for(int i=0;i<p.size();i++)
{
ed=max(ed,p[i]);
if(sw==i)ans+=(rr)*2;
if(ed==i)
{
rr++;
}
ans+=abs(i-p[i]);
}
return ans;
}
Compilation message (stderr)
# | 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... |