# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
72691 | mhnd | 고대 책들 (IOI17_books) | C++14 | 225 ms | 103012 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;
typedef long long ll;
typedef unsigned long long ull;
const int N = 2e5+50;
const int oo = 1e9;
const int mod = 1e9+7;
ll minimum_walk(vector<int> p, int s) {
ll ans = 0;
int mx=-1;
for(int i=0;i<p.size();i++){
ans += abs(i-p[i]);
mx = max(mx,p[i]);
if(mx==i)ans+=2;
}
for(int i=0;i<s;i++){
if(p[i]!=i)continue;
ans-=2;
}
for(int i=p.size()-1;i>s;i--){
if(p[i]!=i)break;
ans-=2;
}
return ans - 2;
}
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... |