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 long double ld;
typedef unsigned long long ull;
const int nax = 1e6+50;
ll ans,sum[nax];
ll minimum_walk(vector<int> p, int s) {
ans = 0;
int n = p.size();
int to = 0;
for(int i=0;i<n;i++){
int l = min(i,p[i]);
int r = max(i,p[i]);
sum[l]++;
sum[r]--;
if(i != p[i])
to = i;
}
for(int i=0;i<to;i++){
if(i)sum[i] += sum[i-1];
ans += max(2ll,sum[i]);
}
return ans;
}
# | 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... |