Submission #420729

#TimeUsernameProblemLanguageResultExecution timeMemory
420729EJOI2019AndrewAncient Books (IOI17_books)C++14
22 / 100
2053 ms58532 KiB
#include "books.h" #include<bits/stdc++.h> using namespace std; long long minimum_walk(std::vector<int> p, int s) { map<int,int>v; int n=p.size(); long long int a(0); int c(0); for(int i=0;i<n;++i) { a+=abs(i-p[i]); for(int j=min(i,p[i]);j<max(i,p[i]);++j) v[j]=1; } for(int i=0;i<n-1;++i) { if(!v[i]) ++c; else { a+=2*c; c=0; } } return a; }
#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...