Submission #120033

#TimeUsernameProblemLanguageResultExecution timeMemory
120033dsjongAncient Books (IOI17_books)C++14
22 / 100
139 ms22904 KiB
#include "books.h" #include <bits/stdc++.h> using namespace std; bool vis[1005]; long long minimum_walk(vector<int> p, int s) { int n=p.size(); long long ans=0; for(int i=0;i<n;i++){ ans+=abs(i-p[i]); for(int j=min(i,p[i])+1;j<=max(i,p[i]);j++){ vis[j]=true; } } int k=-1; for(int i=n-1;i>=0;i--){ if(p[i]!=i){ k=i; break; } } k++; for(int i=1;i<k;i++){ if(!vis[i]){ 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...