제출 #770131

#제출 시각아이디문제언어결과실행 시간메모리
770131APROHACKAncient Books (IOI17_books)C++14
12 / 100
1 ms212 KiB
#include "books.h" #include <bits/stdc++.h> #define ll long long #define ff first #define ss second #define pb push_back using namespace std; int n; int startTo[1000000]; int searchR(int pos){ for(int i = pos ; i < n ; i ++){ if(startTo[i] != -1)return i; } return -1; } int searchL(int pos){ for(int i = 0 ; i < n; i ++){ if(startTo[i] != -1)return i; } return -1; } int pos = 0, temp; ll ans = 0; void ir(int siguiente){ ans += abs(siguiente-pos); pos = siguiente; } long long minimum_walk(std::vector<int> p, int s) { n = p.size(); int cont = 0; for(int i = 0 ; i < n ; i ++){ startTo[i] = -1; if(p[i] > i){ startTo[i] = p[i]; cont ++; } } while(true){ int nextL = searchL(pos); if(nextL != -1){ ir(nextL); temp = pos; ir(startTo[pos]); startTo[temp] = -1; continue; } ans+= pos; 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...