This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "shortcut.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair <int, int >
#define f first
#define s second
#define MX(a,b) a = max(a,b)
#define MN(a,b) a = min(a,b)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)((x).size())
#ifdef BALBIT
#define bug(...) cerr<<"#"<<__LINE__<<": "<<#__VA_ARGS__<<"- ", _do(__VA_ARGS__)
template<typename T> void _do(T && x) {cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T && x, S && ...y) {cerr<<x<<", "; _do(y...);}
#else
#define bug(...)
#endif // BALBIT
#define pb push_back
#define REP(i,n) for (int i = 0; i<(n); ++i)
#define REP1(i,n) for (int i = 1; i<=(n); ++i)
const int maxn = 1e6+5;
ll p[maxn];
ll d[maxn];
int C;
ll gt(int a, int b, int x, int y) {
if (a>b) swap(a,b);
if (x>y) swap(x,y);
return d[x] + d[y] + min((p[y] - p[x]), C + abs(p[x] - p[a]) + abs(p[y]-p[b]));
}
long long find_shortcut(int n, std::vector<int> l, std::vector<int> _d, int _c)
{
C = _c;
p[0] = 0;
REP(i,n) d[i] =_d[i];
for (int i = 1; i<n; ++i) {
p[i] = l[i-1] + p[i-1];
}
ll re = 1ll<<62;
REP(b,n) REP(a,b) {
ll t = 0;
REP(y,n) REP(x,y) {
MX(t, gt(a,b,x,y));
}
MN(re, t);
}
return re;
}
//
//signed main(){
// ll hi = find_shortcut(9, {10, 10, 10, 10, 10, 10, 10, 10},
//{20, 0, 30, 0, 0, 40, 0, 40, 0}, 30);
// bug(hi);
//}
# | 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... |