제출 #132782

#제출 시각아이디문제언어결과실행 시간메모리
132782Talant고대 책들 (IOI17_books)C++17
0 / 100
2 ms376 KiB
#include "books.h" #include <bits/stdc++.h> #define sc second #define fr first #define mk make_pair #define pb push_back using namespace std; const int N = (1e6 + 5); const int inf = (1e9 + 7); int a[N]; int n; long long ans; long long minimum_walk(vector<int> p, int s) { n = p.size(); s ++; for (int i = 0; i < n; i ++) a[i + 1] = p[i] + 1,ans += abs(p[i] - i); int last = s; for (int i = 1; i <= n; i ++) { if (a[i] > i) { ans += abs(last - i); last = a[i]; } } for (int i = 1; i <= n; i ++) { if (i > a[i]) { ans += abs(last - i); last = a[i]; } } return (ans + abs(s - last)); }
#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...