제출 #120029

#제출 시각아이디문제언어결과실행 시간메모리
120029dsjong고대 책들 (IOI17_books)C++14
0 / 100
2 ms256 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[i]=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...