Submission #831597

# Submission time Handle Problem Language Result Execution time Memory
831597 2023-08-20T11:06:51 Z OrazB Shortcut (IOI16_shortcut) C++14
0 / 100
1 ms 304 KB
#include <bits/stdc++.h>
#include "shortcut.h"
using namespace std;
#define ll long long

const int N = 1e5+5;
ll pref[N], suff[N], p[N];

ll dis(int l, int r, vector<int> d){
    if (l > r) swap(l, r);
    if (l == r) return d[l];
    ll x = p[r-1]+d[l]+d[r];
    if (l) x -= p[l-1];
    return x;
}

ll find_shortcut(int n, vector<int> l, vector<int> d, int c){
    // for (int i = 0; i < n; i++){
    //     ll sum = 0;
    //     pref[i] = suff[i] = d[i];
    //     for (int j = i-1; j >= 0; j--){
    //         sum += l[j];
    //         pref[i] = max(pref[i], sum+d[j]); 
    //     }
    //     sum = l[i];
    //     for (int j = i+1; j < n; j++){
    //         suff[i] = max(suff[i], sum+d[j]);
    //         if (j == n-1) break;
    //         sum += l[j];
    //     }
    // }
    for (int i = 0; i < n-1; i++){
        p[i] = l[i];
        if (i) p[i] += p[i-1];
    }
    // cout << dis(1, 3, d);
    ll mn = 1e18;
    for (int i = 0; i < n; i++){
        for (int j = i+1; j < n; j++){
           ll mx = 0;
            for (int x = 0; x < n; x++){
                for (int k = i; k <= j; k++){
                    ll minn = dis(x, k, d);
                    if (x < k) minn = min(minn, dis(x, i, d)+c+dis(k, j, d));
                    else minn = min(minn, dis(x, j, d)+c+dis(i, k, d));
                    // if (x == 1 and k == 3 and i == 0 and j == 3) cout << dis(x,i,d) << '\n';
                    mx = max(mx, minn);
                }
            }
            mn = min(mn, mx);
            // if (mn == 60) cout << i << " " << j << '\n';
        }
    }
    return mn;
}

// int main()
// {
//     int n, c;
//     assert(2 == scanf("%d%d", &n, &c));
    
//     std::vector<int> l(n - 1);
//     std::vector<int> d(n);
//     for (int i = 0; i < n - 1; i++)
//         assert(1 == scanf("%d", &l[i]));
//     for (int i = 0; i < n; i++)
//         assert(1 == scanf("%d", &d[i]));
        
//     long long t = find_shortcut(n, l, d, c);
    
    
//     printf("%lld\n", t);
    
//     return 0;
// }
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB n = 4, 80 is a correct answer
2 Incorrect 1 ms 304 KB n = 9, incorrect answer: jury 110 vs contestant 80
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB n = 4, 80 is a correct answer
2 Incorrect 1 ms 304 KB n = 9, incorrect answer: jury 110 vs contestant 80
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB n = 4, 80 is a correct answer
2 Incorrect 1 ms 304 KB n = 9, incorrect answer: jury 110 vs contestant 80
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB n = 4, 80 is a correct answer
2 Incorrect 1 ms 304 KB n = 9, incorrect answer: jury 110 vs contestant 80
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB n = 4, 80 is a correct answer
2 Incorrect 1 ms 304 KB n = 9, incorrect answer: jury 110 vs contestant 80
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB n = 4, 80 is a correct answer
2 Incorrect 1 ms 304 KB n = 9, incorrect answer: jury 110 vs contestant 80
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB n = 4, 80 is a correct answer
2 Incorrect 1 ms 304 KB n = 9, incorrect answer: jury 110 vs contestant 80
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB n = 4, 80 is a correct answer
2 Incorrect 1 ms 304 KB n = 9, incorrect answer: jury 110 vs contestant 80
3 Halted 0 ms 0 KB -