제출 #152502

#제출 시각아이디문제언어결과실행 시간메모리
152502groeneprof고대 책들 (IOI17_books)C++14
0 / 100
3 ms376 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; long long minimum_walk(vector<int> p, int s) { int i = s; int j = s-1;//incl-incl int mi = s, ma=s; int n = p.size(); long long cnt = 0; while(i!=0||j!=n-1){ bool bol = false; while(mi < i){ bol = true; i--; mi = min(mi, p[i]); ma = max(ma, p[i]); } while(j<ma){ bol = true; j++; mi = min(mi, p[j]); ma = max(ma, p[j]); } if(!bol){ cnt+=2; if(mi>0){mi--;} if(ma<n-1){ma++;} } } //cout<<cnt<<endl; for(int ii = 0; ii<n; ii++){ cnt += abs(ii - p[ii]); } return cnt; }
#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...