Submission #1052319

#TimeUsernameProblemLanguageResultExecution timeMemory
10523190npataAncient Books (IOI17_books)C++17
50 / 100
101 ms8192 KiB
#include "books.h" #include<bits/stdc++.h> using namespace std; #define int long long #define vec vector long long minimum_walk(std::vector<int32_t> P, int32_t S) { int ans = 0; int N = P.size(); for(int i = 0; i<N; i++) { ans += abs(P[i]-i); } int r = P[0]; for(int i = 1; i<N; i++) { if(r < i) ans += 2; r = max((int) P[i], r); } for(int i = 0; i<S; i++) { if(P[i] != i) break; ans -= 2; } for(int i = N-1; i>S; i--) { if(P[i] != i) break; ans -= 2; } 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...