Submission #70703

# Submission time Handle Problem Language Result Execution time Memory
70703 2018-08-23T08:59:46 Z top34051 Shortcut (IOI16_shortcut) C++17
0 / 100
3 ms 556 KB
#include "shortcut.h"
#include<bits/stdc++.h>
using namespace std;

#define ll long long
const int maxn = 3000 + 5;

int n;
ll cost;
ll len[maxn], val[maxn];
ll sum[maxn];
ll L[maxn], R[maxn], mxL[maxn], mxR[maxn];

ll solve() {
    for(int s=0;s<n;s++) sum[s] = sum[s-1] + len[s-1];
    ll tmp;
    tmp = 0;
    for(int s=0;s<n;s++) {
        mxL[s] = max(mxL[s-1], tmp + val[s]);
        tmp = max(tmp, val[s]);
        L[s] = tmp;
        tmp += len[s];
    }
    tmp = 0;
    for(int t=n-1;t>=0;t--) {
        mxR[t] = max(mxR[t+1], tmp + val[t]);
        tmp = max(tmp, val[t]);
        R[t] = tmp;
        tmp += len[t-1];
    }
    ll ans = mxL[n-1];
    for(int s=0;s<n;s++) {
        for(int t=s+1;t<n;t++) {
            ll tmp = 0;
//            printf("(%d, %d)\n",s,t);
            //out - out
            tmp = max(tmp, max(max(mxL[s], mxR[t]), L[s] + R[t] + cost));
            //in - in
            for(int x=s;x<=t;x++) {
                for(int y=x+1;y<=t;y++) {
                    tmp = max(tmp, min(sum[x]-sum[y]-sum[s]+sum[t]+cost, sum[y]-sum[x]) + val[x] + val[y]);
                }
            }
            //in - out
            for(int x=s;x<=t;x++) {
                tmp = max(tmp, min(sum[x]-sum[s], sum[t]-sum[x]+cost) + val[x] + L[s]);
                tmp = max(tmp, min(sum[x]-sum[s]+cost, sum[t]-sum[x]) + val[x] + R[t]);
            }
            ans = min(ans, tmp);
//            printf("\tcost = %lld\n",tmp);
        }
    }
    return ans;
}

ll find_shortcut(int N, vector<int> l, vector<int> d, int c) {
    n = N; cost = c;
    for(int i=0;i<n-1;i++) len[i] = l[i];
    for(int i=0;i<n;i++) val[i] = d[i];
    return solve();
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 248 KB n = 4, 80 is a correct answer
2 Correct 3 ms 488 KB n = 9, 110 is a correct answer
3 Correct 3 ms 556 KB n = 4, 21 is a correct answer
4 Correct 3 ms 556 KB n = 3, 4 is a correct answer
5 Incorrect 3 ms 556 KB n = 2, incorrect answer: jury 62 vs contestant 71
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 248 KB n = 4, 80 is a correct answer
2 Correct 3 ms 488 KB n = 9, 110 is a correct answer
3 Correct 3 ms 556 KB n = 4, 21 is a correct answer
4 Correct 3 ms 556 KB n = 3, 4 is a correct answer
5 Incorrect 3 ms 556 KB n = 2, incorrect answer: jury 62 vs contestant 71
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 248 KB n = 4, 80 is a correct answer
2 Correct 3 ms 488 KB n = 9, 110 is a correct answer
3 Correct 3 ms 556 KB n = 4, 21 is a correct answer
4 Correct 3 ms 556 KB n = 3, 4 is a correct answer
5 Incorrect 3 ms 556 KB n = 2, incorrect answer: jury 62 vs contestant 71
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 248 KB n = 4, 80 is a correct answer
2 Correct 3 ms 488 KB n = 9, 110 is a correct answer
3 Correct 3 ms 556 KB n = 4, 21 is a correct answer
4 Correct 3 ms 556 KB n = 3, 4 is a correct answer
5 Incorrect 3 ms 556 KB n = 2, incorrect answer: jury 62 vs contestant 71
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 248 KB n = 4, 80 is a correct answer
2 Correct 3 ms 488 KB n = 9, 110 is a correct answer
3 Correct 3 ms 556 KB n = 4, 21 is a correct answer
4 Correct 3 ms 556 KB n = 3, 4 is a correct answer
5 Incorrect 3 ms 556 KB n = 2, incorrect answer: jury 62 vs contestant 71
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 248 KB n = 4, 80 is a correct answer
2 Correct 3 ms 488 KB n = 9, 110 is a correct answer
3 Correct 3 ms 556 KB n = 4, 21 is a correct answer
4 Correct 3 ms 556 KB n = 3, 4 is a correct answer
5 Incorrect 3 ms 556 KB n = 2, incorrect answer: jury 62 vs contestant 71
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 248 KB n = 4, 80 is a correct answer
2 Correct 3 ms 488 KB n = 9, 110 is a correct answer
3 Correct 3 ms 556 KB n = 4, 21 is a correct answer
4 Correct 3 ms 556 KB n = 3, 4 is a correct answer
5 Incorrect 3 ms 556 KB n = 2, incorrect answer: jury 62 vs contestant 71
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 248 KB n = 4, 80 is a correct answer
2 Correct 3 ms 488 KB n = 9, 110 is a correct answer
3 Correct 3 ms 556 KB n = 4, 21 is a correct answer
4 Correct 3 ms 556 KB n = 3, 4 is a correct answer
5 Incorrect 3 ms 556 KB n = 2, incorrect answer: jury 62 vs contestant 71
6 Halted 0 ms 0 KB -