Submission #1046055

#TimeUsernameProblemLanguageResultExecution timeMemory
1046055Gromp15Shortcut (IOI16_shortcut)C++17
0 / 100
1 ms412 KiB
#include "shortcut.h" #include <bits/stdc++.h> #define ll long long using namespace std; template<typename T> bool ckmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; } template<typename T> bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; } long long find_shortcut(int n, std::vector<int> l, std::vector<int> d, int c) { ll ans = 1e18; vector<ll> p(n); for (int i = 1; i < n; i++) p[i] = p[i-1] + l[i-1]; for (int i = 0; i < n; i++) { for (int j = i+1; j < n; j++) { ll cur = 0; for (int k = 0; k <= i; k++) { for (int l = k+1; l <= j; l++) { ckmax(cur, d[k] + d[l] + min(p[l], p[i] + p[j] - p[l] + c) - p[k]); } for (int l = max(k+1, j+1); l < n; l++) { ckmax(cur, d[k] + d[l] + p[l] - p[k]); } } for (int k = i+1; k < n; k++) { for (int l = k+1; l <= j; l++) { ckmax(cur, d[k] + d[l] + min(p[l] - p[k], p[k] - p[i] + p[j] - p[l] + c)); } for (int l = max(j+1, k+1); l < n; l++) { ckmax(cur, d[k] + d[l] + p[l] - p[k]); } } ckmin(ans, cur); } } 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...