| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1266292 | gustavo_d | Shortcut (IOI16_shortcut) | C++20 | 2095 ms | 444 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;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
