Submission #133384

#TimeUsernameProblemLanguageResultExecution timeMemory
133384Osama_AlkhodairyAncient Books (IOI17_books)C++17
50 / 100
181 ms18860 KiB
#include <bits/stdc++.h> //~ #include "grader.cpp" #include "books.h" using namespace std; #define ll long long long long minimum_walk(std::vector<int> p, int s) { int n = p.size(); vector <int> c(n); ll ret = 0; for(int i = 0 ; i < n ; i++){ ret += abs(i - p[i]); int l = i, r = p[i]; if(l > r) swap(l, r); c[l]++; c[r]--; } for(int i = 1 ; i < n ; i++){ c[i] += c[i - 1]; } int cur = 0; for(int i = 0 ; i < n - 1 ; i++){ if(c[i] == 0) cur++; else{ ret += 2 * cur; cur = 0; } } return ret; }
#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...