Submission #1028661

#TimeUsernameProblemLanguageResultExecution timeMemory
1028661parsadox2Ancient Books (IOI17_books)C++17
22 / 100
75 ms15864 KiB
#include "books.h" #include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; int a[N] , n; bool marked[N]; long long minimum_walk(vector<int> p, int s) { n = p.size(); int ans = 0 , cnt = (p[0] == 0 ? 0 : 1); marked[p[0]] = true; for(int i = 1 ; i < n ; i++) { ans += max(2 * cnt , 2); if(p[i] > i) { cnt++; marked[p[i]] = true; } if(marked[i]) cnt--; } for(int i = n - 1 ; i >= 1 ; 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...