Submission #1266292

#TimeUsernameProblemLanguageResultExecution timeMemory
1266292gustavo_dShortcut (IOI16_shortcut)C++20
31 / 100
2095 ms444 KiB
#include "shortcut.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAXN = 3000; const ll INF = 1e18; int n; ll pf[MAXN], sf[MAXN], pos[MAXN], branch[MAXN]; ll find_shortcut(int N, vector<int> l, vector<int> d, int c) { n = N; ll ans = INF; for (int i=0; i<n; i++) { for (int j=i+1; j<n; j++) { ll res = 0; pf[0] = d[0]; for (int k=0; k<i; k++) { pf[k+1] = max(pf[k] + l[k], (ll)d[k+1]); } sf[i] = d[i]; for (int k=i-1; k>=0; k--) { sf[k] = max((ll)d[k], sf[k+1] + l[k]); } for (int k=0; k<i; k++) { res = max(res, pf[k] + sf[k+1] + l[k]); } branch[i] = pf[i]; pf[j] = d[j]; for (int k=j; k<n; k++) { pf[k+1] = max(pf[k] + l[k], (ll)d[k+1]); } sf[n-1] = d[n-1]; for (int k=n-2; k>=j; k--) { sf[k] = max((ll)d[k], sf[k+1] + l[k]); } for (int k=j; k<n-1; k++) { res = max(res, pf[k] + sf[k+1] + l[k]); } branch[j] = sf[j]; pos[i] = 0; for (int k=i+1; k<j; k++) { pos[k] = pos[k-1] + l[k-1]; branch[k] = d[k]; } pos[j] = pos[j-1] + l[j-1]; // cout << i << ' ' << j << ": "; // for (int k=i; k<=j; k++) { // cout << pos[k] << ' ' << branch[k] << ','; // } // cout << endl; for (int a=i; a<=j; a++) { for (int b=a+1; b<=j; b++) { res = max( res, min(pos[b] - pos[a], pos[j] + c - (pos[b] - pos[a])) + branch[a] + branch[b] ); } } // cout << res << endl; ans = min(ans, res); } } return ans; }

Compilation message (stderr)

shortcut.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
shortcut_c.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
#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...