# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
775908 | peteza | Ancient Books (IOI17_books) | C++14 | 1 ms | 312 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;
int qs[1000005];
long long minimum_walk(std::vector<int> p, int s) {
int cur = 0, cv = 0;
long long cans = 0;
for(int i=0;i<p.size();i++) {
qs[min(i, p[i])]++; qs[max(i, p[i])]--;
}
for(int i=0;i<p.size();i++) {
if(qs[i] && !cv) cur = i;
cv += qs[i];
//cout << qs[i] << ' ';
cans += cv;
}
return cans + 2*cur;
}
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... |