# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
71604 | idan_izmirli | Ancient Books (IOI17_books) | C++14 | 209 ms | 10176 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"
long long minimum_walk(std::vector<int> p, int s) {
long long result=-2;
int current_max=0;
for(int i=0;i<p.size();i++)
{
if(p[i]<i)
{
result+=i-p[i];
}
else
{
result+=p[i]-i;
}
if(p[i]>current_max)
{
current_max=p[i];
}
if(current_max==i)
{
result+=2;
}
}
for(int i=0;i<s;i++)
{
if(p[i]!=i)
{
break;
}
result-=2;
}
for(int i=p.size()-1;i>s;i--)
{
if(p[i]!=i)
{
break;
}
result-=2;
}
return result;
}
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... |