Submission #407149

#TimeUsernameProblemLanguageResultExecution timeMemory
407149rocks03Shortcut (IOI16_shortcut)C++14
23 / 100
2081 ms292 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int, int> #define pll pair<ll, ll> #define ff first #define ss second #define pb push_back #define SZ(x) ((int)(x).size()) #define all(x) x.begin(), x.end() #define debug(x) cout << #x << ": " << x << " " #define nl cout << "\n" #define rep(i, a, b) for(int i = (a); i <= (b); i++) #define per(i, a, b) for(int i = (a); i >= (b); i--) mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); long long find_shortcut(int N, vector<int> l, vector<int> p, int C){ vector<ll> L(N), P(N); rep(i, 0, N - 1){ if(i) L[i] = L[i - 1] + l[i - 1]; P[i] = p[i]; } auto dist = [&](int i, int j, int l, int r){ ll ans = P[i] + P[j] + min({L[j] - L[i], C + abs(L[j] - L[r]) + abs(L[l] - L[i]), C + abs(L[j] - L[l])+ abs(L[r] - L[i])}); return ans; }; auto diameter = [&](int l, int r){ ll ans = 0; rep(i, 0, N - 1){ rep(j, i + 1, N - 1){ ans = max(ans, dist(i, j, l, r)); } } return ans; }; ll ans = LLONG_MAX; rep(i, 0, N - 1){ rep(j, i + 1, N - 1){ ans = min(ans, diameter(i, j)); } } 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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...