# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
420292 | Andyvanh1 | Ancient Books (IOI17_books) | C++14 | 164 ms | 14936 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 <bits/stdc++.h>
#include "books.h"
using namespace std;
#define vt vector
#define INF 0x3f3f3f3f
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,x) for(int (i) = 0;(i) < (x); (i)++)
#define MOD 1000000007
typedef vt<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
ll minimum_walk(vi p, int s){
for(int i = p.size()-1; i>=0; i--){
if(p[i]==i)p.pop_back();
else break;
}
ll ans = 0;
int curlast = 0;
int n = p.size();
rep(i,n)ans+=1ll*(abs(p[i]-i));
for(int i = 0; i < n; i++){
if(i>curlast)ans+=2;
curlast = max(curlast,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... |