Submission #1015145

# Submission time Handle Problem Language Result Execution time Memory
1015145 2024-07-06T06:43:16 Z 김은성(#10845) Shortcut (IOI16_shortcut) C++14
0 / 100
1 ms 348 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;
    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]);
                }
                cur = max(cur, mx - p[i] + d[i]);
            }
            cur=0;
            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]);
                }
                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]));
            }
            mx = -INF;
            for(j=l; j<n; j++){
                mx = max(mx, d[j] + p[j]);
            }
            for(i=k; i<=l; i++){
                cur = max(cur, mx+d[i] + min(-p[i], -p[l]-p[k]+p[i]+c));
            }
            printf("k=%d l=%d cur=%lld\n", k, l, cur);
            ans = min(ans, cur);
        }
    }
    return ans;
}

Compilation message

shortcut.cpp: In function 'long long int find_shortcut(int, std::vector<int>, std::vector<int>, int)':
shortcut.cpp:9:12: warning: unused variable 'j' [-Wunused-variable]
    9 |     int i, j, k, l;
      |            ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Secret is incorrect!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Secret is incorrect!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Secret is incorrect!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Secret is incorrect!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Secret is incorrect!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Secret is incorrect!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Secret is incorrect!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Secret is incorrect!
2 Halted 0 ms 0 KB -