#include "shortcut.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll find_shortcut(int n, vector<int> l, vector<int> d, int c){
vector<ll> ps(n, 0);
for (int i=0; i<n-1; i++) ps[i+1] = ps[i]+l[i];
ll bsf = (1ll<<50);
for (int i=0; i<n; i++){
for (int j=i+1; j<n; j++){
ll cur = 0;
vector<int> v;
//for (int k=0; k<n; k++) v.push_back(k);
pair<int,int> bl = {-1, -1}, br = {-1, -1};
for (int k=0; k<i; k++){
bl = max(bl, {d[k]+ps[n-1]-ps[k], k});
br = max(br, {d[k]+ps[k], k});
}
v.push_back(bl.second);
v.push_back(br.second);
bl = {-1, -1}; br = {-1, -1};
for (int k=i; k<=j; k++){
bl = max(bl, {d[k]+ps[n-1]-ps[k], k});
br = max(br, {d[k]+ps[k], k});
}
v.push_back(bl.second);
v.push_back(br.second);
bl = {-1, -1}; br = {-1, -1};
for (int k=j+1; k<n; k++){
bl = max(bl, {d[k]+ps[n-1]-ps[k], k});
br = max(br, {d[k]+ps[k], k});
}
v.push_back(bl.second);
v.push_back(br.second);
for (int x : v){
for (int y=0; y<n; y++){
if (y == x) continue;
ll dist = min(d[x]+d[y]+abs(ps[y]-ps[x]), d[x]+d[y]+c+min(abs(ps[x]-ps[i])+abs(ps[y]-ps[j]), abs(ps[y]-ps[i])+abs(ps[x]-ps[j])));
cur = max(cur, dist);
}
}
bsf = min(bsf, cur);
}
}
return bsf;
}
컴파일 시 표준 에러 (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 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... |