Submission #58445

#TimeUsernameProblemLanguageResultExecution timeMemory
58445realityAncient Books (IOI17_books)C++17
0 / 100
4 ms356 KiB
#include "books.h" #include "bits/stdc++.h" using namespace std; #define fi first #define se second #define ll long long #define dbg(v) cerr<<#v<<" = "<<v<<'\n' #define vi vector<int> #define vl vector <ll> #define pii pair<int,int> #define mp make_pair #define db long double #define pb push_back #define all(s) s.begin(),s.end() template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;} template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;} #include "books.h" long long minimum_walk(std::vector<int> p, int s) { int n = p.size(); ll ans = 0; for (int i = 0;i < n;++i) ans += abs(i - p[i]); dbg(ans); int mx = 0; for (int i = 0;i + 1 < n;++i) smax(mx,p[i]),ans += 2 * (i == mx); 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...