Submission #1030970

# Submission time Handle Problem Language Result Execution time Memory
1030970 2024-07-22T13:03:05 Z kym Shortcut (IOI16_shortcut) C++14
0 / 100
0 ms 348 KB
#include "shortcut.h"
#include <bits/stdc++.h>
using namespace std;
#define int long long 
const int maxn=3005;
int X[maxn];
vector<int32_t> L, D;
int C;
int n;
const int oo = 1'000'000'000'000'000'000ll;
typedef pair<int,int>pi;
int get(int L, int R){
    int dl=0,dr=0;
    for(int i=0;i<=L;i++)dl=max(dl,-X[i]+D[i]);
    for(int i=R;i<n;i++)dr=max(dr,X[i]+D[i]);
    int ans=0;
    ans=max(ans,dl+dr+min(X[R]-X[L],C)+X[L]-X[R]);

    int m1=0;
    for(int i=L;i<=R;i++){
        m1=max(m1,D[i] + min(X[i]-X[L], X[R]-X[i]+C));
    }
    ans=max(ans,m1 + dl+X[L]);
    int m2=0;
    for(int i=L;i<=R;i++){
        m2=max(m2,D[i] + min(X[R]-X[i], X[i]-X[L]+C));
    }
    ans=max(ans,m2+dr-X[R]);
    int bet=0;
    for(int i=L;i<=R;i++){
        for(int j=i+1;j<=R;j++){
            bet=max(bet,D[i]+D[j]+min(X[j]-X[i],C+X[i]-X[L]+X[R]-X[j]));
        }
    }
    ans=max(ans,bet);
    //ans=max(ans,longest(ls));
    //what if they just don't use it
    m1=0,m2=0;
    for(int i=0;i<=L;i++){
        m1=max(m1,X[i]+D[i]);
        m2=max(m2,-X[i]+D[i]);
    }
    ans=max(ans,m1+m2);
    m1=0,m2=0;
    for(int i=R;i<n;i++){
        m1=max(m1,X[i]+D[i]);
        m2=max(m2,-X[i]+D[i]);
    }
    ans=max(ans,m1+m2);
    return ans;
}
long long find_shortcut(int32_t n, vector<int32_t> l, vector<int32_t> d, int32_t c)
{
    L=l;D=d;C=c;
    ::n=n;
    for(int i=1;i<n;i++){
        X[i]=X[i-1]+l[i-1];
    }  
    int ans=oo;
    for(int i=0;i<n;i++){
        for(int j=i;j<n;j++){
            ans=min(ans,get(i,j));
        }
    }

    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB n = 4, 80 is a correct answer
2 Correct 0 ms 348 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 0 ms 348 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB n = 4, 80 is a correct answer
2 Correct 0 ms 348 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 0 ms 348 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB n = 4, 80 is a correct answer
2 Correct 0 ms 348 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 0 ms 348 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB n = 4, 80 is a correct answer
2 Correct 0 ms 348 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 0 ms 348 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB n = 4, 80 is a correct answer
2 Correct 0 ms 348 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 0 ms 348 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB n = 4, 80 is a correct answer
2 Correct 0 ms 348 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 0 ms 348 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB n = 4, 80 is a correct answer
2 Correct 0 ms 348 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 0 ms 348 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB n = 4, 80 is a correct answer
2 Correct 0 ms 348 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 0 ms 348 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -