Submission #1015171

# Submission time Handle Problem Language Result Execution time Memory
1015171 2024-07-06T06:59:32 Z 김은성(#10845) Shortcut (IOI16_shortcut) C++14
0 / 100
1 ms 600 KB
#include "shortcut.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll p[200009];
const ll INF = 0x3fffffffffffffffll;
long long find_shortcut(int n, std::vector<int> L, std::vector<int> d, int c)
{
    int i, j, k, l;
    for(i=0; i<n-1; i++){
        p[i+1] = p[i] + L[i];
    }
    ll ans = INF, org = 0;
    for(i=0; i<n; i++){
        for(j=i+1; j<n; j++){
            org = max(org, p[j]+d[j] - p[i]+d[i]);
        }
    }
    ans = org;
    for(k=0; k<n; k++){
        for(l=k+1; l<n; l++){
            ll cur = 0;
            int j = k;
            ll mx = p[k] + d[k];
            for(i=k; i<=l; i++){
                while(j<l && p[j+1]-p[i] < c + p[l]+p[i]-p[k]-p[j+1]){
                    j++;
                    mx = max(mx, p[j] + d[j]);
                }
                //printf("i=%d j=%d mx=%lld p[i]=%d d[i]=%d\n", i, j, mx, p[i], d[i]);
                cur = max(cur, mx - p[i] + d[i]);
            }
            j = l+1;
            mx = -INF;
            for(i=l; i>=k; i--){
                while(j>k && p[j-1]-p[i] >= c + p[l]+p[i]-p[k]-p[j-1]){
                    j--;
                    mx = max(mx, d[j] - p[j]);
                }
               // printf("i=%d j=%d\n", i, j);
                cur = max(cur, c + p[l] + p[i] + d[i] - p[k] + mx);
            }
            //printf("cur=%lld\n", cur);
            mx = -INF;
            for(i=0; i<k; i++){
                mx = max(mx, d[i] - p[i]);
            }
            for(j=k; j<=l; j++){
                cur = max(cur,mx + d[j] + min(p[j], c + p[l] + p[k] - p[j]));
            }
            ll mx2 = -INF;
            for(j=l+1; j<n; j++){
                mx2 = max(mx2, d[j] + p[j]);
            }
            for(i=k; i<=l; i++){
                cur = max(cur, mx2+d[i] + min(-p[i], -p[l]-p[k]+p[i]+c));
            }
            mx = max(mx, d[k]-p[k]);
            mx2 = max(mx2, d[l]+p[l]);
            cur = max(cur, mx + mx2 - p[l] + p[k] + c);
            //printf("k=%d l=%d cur=%lld\n", k, l, cur);
            ans = min(ans, cur);
        }
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB n = 4, 80 is a correct answer
2 Correct 0 ms 344 KB n = 9, 110 is a correct answer
3 Correct 0 ms 348 KB n = 4, 21 is a correct answer
4 Correct 0 ms 348 KB n = 3, 4 is a correct answer
5 Incorrect 1 ms 348 KB n = 2, incorrect answer: jury 62 vs contestant 71
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB n = 4, 80 is a correct answer
2 Correct 0 ms 344 KB n = 9, 110 is a correct answer
3 Correct 0 ms 348 KB n = 4, 21 is a correct answer
4 Correct 0 ms 348 KB n = 3, 4 is a correct answer
5 Incorrect 1 ms 348 KB n = 2, incorrect answer: jury 62 vs contestant 71
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB n = 4, 80 is a correct answer
2 Correct 0 ms 344 KB n = 9, 110 is a correct answer
3 Correct 0 ms 348 KB n = 4, 21 is a correct answer
4 Correct 0 ms 348 KB n = 3, 4 is a correct answer
5 Incorrect 1 ms 348 KB n = 2, incorrect answer: jury 62 vs contestant 71
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB n = 4, 80 is a correct answer
2 Correct 0 ms 344 KB n = 9, 110 is a correct answer
3 Correct 0 ms 348 KB n = 4, 21 is a correct answer
4 Correct 0 ms 348 KB n = 3, 4 is a correct answer
5 Incorrect 1 ms 348 KB n = 2, incorrect answer: jury 62 vs contestant 71
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB n = 4, 80 is a correct answer
2 Correct 0 ms 344 KB n = 9, 110 is a correct answer
3 Correct 0 ms 348 KB n = 4, 21 is a correct answer
4 Correct 0 ms 348 KB n = 3, 4 is a correct answer
5 Incorrect 1 ms 348 KB n = 2, incorrect answer: jury 62 vs contestant 71
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB n = 4, 80 is a correct answer
2 Correct 0 ms 344 KB n = 9, 110 is a correct answer
3 Correct 0 ms 348 KB n = 4, 21 is a correct answer
4 Correct 0 ms 348 KB n = 3, 4 is a correct answer
5 Incorrect 1 ms 348 KB n = 2, incorrect answer: jury 62 vs contestant 71
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB n = 4, 80 is a correct answer
2 Correct 0 ms 344 KB n = 9, 110 is a correct answer
3 Correct 0 ms 348 KB n = 4, 21 is a correct answer
4 Correct 0 ms 348 KB n = 3, 4 is a correct answer
5 Incorrect 1 ms 348 KB n = 2, incorrect answer: jury 62 vs contestant 71
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB n = 4, 80 is a correct answer
2 Correct 0 ms 344 KB n = 9, 110 is a correct answer
3 Correct 0 ms 348 KB n = 4, 21 is a correct answer
4 Correct 0 ms 348 KB n = 3, 4 is a correct answer
5 Incorrect 1 ms 348 KB n = 2, incorrect answer: jury 62 vs contestant 71
6 Halted 0 ms 0 KB -