Submission #757273

#TimeUsernameProblemLanguageResultExecution timeMemory
757273SebShortcut (IOI16_shortcut)C++17
23 / 100
2083 ms340 KiB
#include "shortcut.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; #define f first #define s second const ll MAXN = 3e3+5; const ll INF = 1e15; vector <int> L,D; ll C,dist[MAXN],ans = INF; void diametro(ll a, ll b, ll n) { ll di = 0; for (int i=1;i<n;i++) { for (int j=0;j<i;j++) { ll aux = abs(dist[i]-dist[j]); aux = min(aux , abs(dist[a] - dist[j]) + abs(dist[i] - dist[b]) + C); di = max(aux + D[i] + D[j] , di); } } ans = min(ans,di); return; } void bruta(ll n) { for (int i=1;i<n;i++) for (int j=0;j<i;j++) diametro(j,i,n); return; } void crea(ll n) { dist[0] = 0; for (int i=1;i<n;i++) dist[i] = dist[i-1] + L[i-1]; return; } long long find_shortcut(int n, std::vector<int> l, std::vector<int> d, int c) { swap(l,L); swap(d,D); C = c; crea(n); bruta(n); 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...