# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
593991 | AlperenT | Ancient Books (IOI17_books) | C++17 | 142 ms | 22744 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;
long long minimum_walk(vector<int> p, int s){
long long ans = 0, mx = -1, n = p.size();
vector<long long> arr(n + 1, 0);
for(int i = 0; i < n; i++){
arr[min(i, p[i])]++;
arr[max(i, p[i])]--;
}
for(int i = 1; i < n; i++) arr[i] += arr[i - 1];
for(int i = 0; i < n; i++) if(arr[i]) mx = i;
return (mx == -1 ? 0ll : accumulate(arr.begin(), arr.begin() + mx + 1, 0ll) + count(arr.begin(), arr.begin() + mx + 1, 0) * 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... |