제출 #132633

#제출 시각아이디문제언어결과실행 시간메모리
132633MoNsTeR_CuBe고대 책들 (IOI17_books)C++17
0 / 100
2 ms376 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; long long minimum_walk(std::vector<int> p, int s) { #define int long long int l = 0, r = p.size()-1; int maxi = -1; int ans = 0; for(int i = 0; i < (int)p.size(); i++){ if(p[i] != i){ l = i; break; } } for(int i = (int)p.size()-1; i >= 0; i--){ if(p[i] != i){ r = i; break; } } for(int i = l; i <= r; i++){ if(p[i] != i){ ans += abs(p[i]-i); maxi = max(maxi, (int)p[i]); }else if(i >= maxi){ ans += 2; } } return ans + 2*l; #undef int }
#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...