Submission #1022515

#TimeUsernameProblemLanguageResultExecution timeMemory
1022515RaresFelixShortcut (IOI16_shortcut)C++17
23 / 100
2019 ms600 KiB
#include "shortcut.h" #include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vll = vector<ll>; const ll INF = 1e18; ll find_shortcut(int n, vi l, vi d, int c) { vll s(n, 0), alpha(n, 0), beta(n, 0); for(int i = 1; i < n; ++i) { s[i] = s[i - 1] + l[i - 1]; } ll re = INF; auto dist = [&](int i, int j, int a, int b) { if(i > j) swap(i, j); return d[i] + d[j] + min(abs(s[i] - s[j]), abs(s[i] - s[a]) + c + abs(s[j] - s[b])); }; for(int a = 0; a < n; ++a) for(int b = a; b < n; ++b) { ll cre = 0; for(int i = 0; i < n; ++i) for(int j = i + 1; j < n; ++j) cre = max(cre, dist(i, j, a, b)); re = min(re, cre); } return re; }
#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...