Submission #712065

# Submission time Handle Problem Language Result Execution time Memory
712065 2023-03-18T04:25:41 Z bin9638 Shortcut (IOI16_shortcut) C++17
0 / 100
0 ms 212 KB
#include <bits/stdc++.h>

#ifndef SKY
#include "shortcut.h"
#endif // SKY

using namespace std;

#define ll long long
#define pb push_back
#define N 100010
#define ii pair<ll,int>
#define fs first
#define sc second

int n;
ll sum[N],C,d[N];

ll dis(int u,int v,int L,int R)
{
    return d[u]+d[v]+min(abs(sum[u]-sum[v]),min( abs(sum[L]-sum[u])+abs(sum[R]-sum[v])+C, abs(sum[L]-sum[v])+abs(sum[R]-sum[u])+C   ));
}

ll find_shortcut(int cc, vector<int> l, vector<int> DD, int vl)
{
    n=cc;
    C=vl;
    for(int i=2;i<=n;i++)
        sum[i]=1ll*l[i-2]+sum[i-1];
    for(int i=1;i<=n;i++)
        d[i]=DD[i-1];
    ll res=1e18;
    for(int L=1;L<=n;L++)
        for(int R=L+1;R<=n;R++)
        {
           // if(L==2&&R==4)
             //   cout<<dis(2,4,L,R)<<endl;
          /*  int vt=1;
            ll val=0;
            for(int i=2;i<=n;i++)
            {
                ll cc=dis(1,i,L,R);
                if(cc>val)
                {
                    val=cc;
                    vt=i;
                }
            }*/
            ll D=0;
            for(int i=1;i<=n;i++)
                for(int j=1;j<=n;j++)
                    D=max(D,dis(j,i,L,R));
            res=min(res,D);
        }
    return res;
}

#ifdef SKY
int main()
{
    freopen("A.inp","r",stdin);
    freopen("A.out","w",stdout);
    int n,c;
    vector<int>l,d;
    cin>>n;
    for(int i=0;i<n-1;i++)
    {
        int u;
        cin>>u;
        l.pb(u);
    }
    for(int i=0;i<n;i++)
    {
        int u;
        cin>>u;
        d.pb(u);
    }
    cin>>c;
    cout<<find_shortcut(n,l,d,c);
}
#endif
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB n = 4, 80 is a correct answer
2 Correct 0 ms 212 KB n = 9, 110 is a correct answer
3 Correct 0 ms 212 KB n = 4, 21 is a correct answer
4 Correct 0 ms 212 KB n = 3, 4 is a correct answer
5 Incorrect 0 ms 212 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 212 KB n = 4, 80 is a correct answer
2 Correct 0 ms 212 KB n = 9, 110 is a correct answer
3 Correct 0 ms 212 KB n = 4, 21 is a correct answer
4 Correct 0 ms 212 KB n = 3, 4 is a correct answer
5 Incorrect 0 ms 212 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 212 KB n = 4, 80 is a correct answer
2 Correct 0 ms 212 KB n = 9, 110 is a correct answer
3 Correct 0 ms 212 KB n = 4, 21 is a correct answer
4 Correct 0 ms 212 KB n = 3, 4 is a correct answer
5 Incorrect 0 ms 212 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 212 KB n = 4, 80 is a correct answer
2 Correct 0 ms 212 KB n = 9, 110 is a correct answer
3 Correct 0 ms 212 KB n = 4, 21 is a correct answer
4 Correct 0 ms 212 KB n = 3, 4 is a correct answer
5 Incorrect 0 ms 212 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 212 KB n = 4, 80 is a correct answer
2 Correct 0 ms 212 KB n = 9, 110 is a correct answer
3 Correct 0 ms 212 KB n = 4, 21 is a correct answer
4 Correct 0 ms 212 KB n = 3, 4 is a correct answer
5 Incorrect 0 ms 212 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 212 KB n = 4, 80 is a correct answer
2 Correct 0 ms 212 KB n = 9, 110 is a correct answer
3 Correct 0 ms 212 KB n = 4, 21 is a correct answer
4 Correct 0 ms 212 KB n = 3, 4 is a correct answer
5 Incorrect 0 ms 212 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 212 KB n = 4, 80 is a correct answer
2 Correct 0 ms 212 KB n = 9, 110 is a correct answer
3 Correct 0 ms 212 KB n = 4, 21 is a correct answer
4 Correct 0 ms 212 KB n = 3, 4 is a correct answer
5 Incorrect 0 ms 212 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 212 KB n = 4, 80 is a correct answer
2 Correct 0 ms 212 KB n = 9, 110 is a correct answer
3 Correct 0 ms 212 KB n = 4, 21 is a correct answer
4 Correct 0 ms 212 KB n = 3, 4 is a correct answer
5 Incorrect 0 ms 212 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -