Submission #99185

#TimeUsernameProblemLanguageResultExecution timeMemory
99185figter001Ancient Books (IOI17_books)C++14
50 / 100
278 ms22884 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...