이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "shortcut.h"
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
typedef long long ll;
const int N = 502;
const ll INF = 1000000009000000009;
int n;
ll gg;
ll l[N], d[N];
ll p[N], s[N];
ll pp[N], ss[N];
ll pl[N];
long long find_shortcut(int n_, std::vector<int> l_, std::vector<int> d_, int c_)
{
n = n_;
for (int i = 1; i < n; ++i)
l[i] = l_[i - 1];
for (int i = 1; i <= n; ++i)
d[i] = d_[i - 1];
gg = c_;
for (int i = 1; i <= n; ++i)
{
pp[i] = max(pp[i - 1], p[i - 1] + l[i - 1] + d[i]);
p[i] = max(p[i - 1] + l[i - 1], d[i]);
}
for (int i = n; i >= 1; --i)
{
ss[i] = max(ss[i + 1], s[i + 1] + l[i] + d[i]);
s[i] = max(s[i + 1] + l[i], d[i]);
}
for (int i = 1; i <= n; ++i)
pl[i] = pl[i - 1] + l[i - 1];
ll ans = INF;
for (int x1 = 1; x1 <= n; ++x1)
{
for (int x2 = x1 + 1; x2 <= n; ++x2)
{
ll yans = max(pp[x1], ss[x2]);
ll d1 = d[x1];
ll d2 = d[x2];
d[x1] = p[x1];
d[x2] = s[x2];
ll u = pl[x2] - pl[x1];
for (int i = x1; i <= x2; ++i)
{
for (int j = i + 1; j <= x2; ++j)
{
yans = max(yans,
d[i] + d[j] + min(pl[j] - pl[i], u - (pl[j] - pl[i]) + gg));
}
}
d[x1] = d1;
d[x2] = d2;
ans = min(ans, yans);
}
}
return ans;
}
# | 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... |