Submission #1052296

#TimeUsernameProblemLanguageResultExecution timeMemory
10522960npataAncient Books (IOI17_books)C++17
50 / 100
71 ms15084 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]; int lst = 0; for(int i = 0; i<N; i++) { if(P[i] != i) lst = i; } for(int i = 1; i<=lst; i++) { if(r < i) ans += 2; r = max((int) P[i], r); } 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...