Submission #74151

# Submission time Handle Problem Language Result Execution time Memory
74151 2018-08-30T10:09:09 Z MKopchev Shortcut (IOI16_shortcut) C++14
0 / 100
3 ms 528 KB
#include<bits/stdc++.h>
using namespace std;
const int nmax=1e6+42;
long long x[nmax];
long long find_shortcut(int n, vector<int> l, vector<int> d, int c)
{
    long long ans=1e18;
    x[0]=0;
    for(int i=1;i<n;i++)
        x[i]=x[i-1]+l[i-1];
    for(int p=0;p<n;p++)
        for(int q=p+1;q<n;q++)
        {
        long long now=0;
        //1<->1 type
        long long best=-1e18;
        for(int j=0;j<=p;j++)
        {
            now=max(now,d[j]+x[j]+best);
            best=max(best,d[j]-x[j]);
        }
                //if(p==2&&q==7)cout<<now<<endl;
        //3<->3 type
        best=-1e18;
        for(int j=q;j<n;j++)
        {
            now=max(now,d[j]+x[j]+best);
            best=max(best,d[j]-x[j]);
        }
               //if(p==2&&q==7)cout<<now<<endl;
        //1<->3 type
        best=-1e18;
        for(int i=0;i<=p;i++)
            best=max(best,d[i]+x[p]-x[i]);
        for(int j=q;j<n;j++)
            now=max(now,d[j]+x[j]-x[q]+best+min(1LL*c,x[q]-x[p]));
                //if(p==2&&q==7)cout<<best<<" "<<now<<endl;
        //1<->2 type
        best=-1e18;
        for(int i=0;i<=p;i++)
            best=max(best,d[i]-x[i]+x[p]);
        for(int j=p;j<=q;j++)
            now=max(now,best+d[j]+min(x[j]-x[p],x[q]-x[j]+c));
                //if(p==2&&q==7)cout<<now<<endl;
        //2<->3 type
        best=-1e18;
        for(int i=p;i<=q;i++)
            best=max(best,d[i]+min(x[i]-x[p]+c,x[q]-x[i]));
        for(int j=q;j<n;j++)
            now=max(now,best+d[j]+x[j]-x[q]);
                    //if(p==2&&q==7)cout<<now<<endl;
        //2<->2 type
        for(int i=p;i<=q;i++)
            for(int j=i;j<=q;j++)
            now=max(now,d[i]+d[j]+min(x[j]-x[i],x[q]-x[j]+c+x[i]-x[p]));
        //if(now==100)cout<<p<<" "<<q<<endl;
            //if(p==2&&q==7)cout<<now<<endl;
        ans=min(ans,now);
        }
    return ans;
}
/*
int main()
{
//cout<<find_shortcut(9, {10, 10, 10, 10, 10, 10, 10, 10},{20, 0, 30, 0, 0, 40, 0, 40, 0}, 30)<<endl;
//cout<<find_shortcut(4, {2, 2, 2},{1, 10, 10, 1}, 1)<<endl;
cout<<find_shortcut(3, {1, 1},{1, 1, 1}, 3)<<endl;

return 0;
}
*/
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB n = 4, 80 is a correct answer
2 Correct 2 ms 484 KB n = 9, 110 is a correct answer
3 Correct 2 ms 528 KB n = 4, 21 is a correct answer
4 Correct 2 ms 528 KB n = 3, 4 is a correct answer
5 Incorrect 2 ms 528 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB n = 4, 80 is a correct answer
2 Correct 2 ms 484 KB n = 9, 110 is a correct answer
3 Correct 2 ms 528 KB n = 4, 21 is a correct answer
4 Correct 2 ms 528 KB n = 3, 4 is a correct answer
5 Incorrect 2 ms 528 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB n = 4, 80 is a correct answer
2 Correct 2 ms 484 KB n = 9, 110 is a correct answer
3 Correct 2 ms 528 KB n = 4, 21 is a correct answer
4 Correct 2 ms 528 KB n = 3, 4 is a correct answer
5 Incorrect 2 ms 528 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB n = 4, 80 is a correct answer
2 Correct 2 ms 484 KB n = 9, 110 is a correct answer
3 Correct 2 ms 528 KB n = 4, 21 is a correct answer
4 Correct 2 ms 528 KB n = 3, 4 is a correct answer
5 Incorrect 2 ms 528 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB n = 4, 80 is a correct answer
2 Correct 2 ms 484 KB n = 9, 110 is a correct answer
3 Correct 2 ms 528 KB n = 4, 21 is a correct answer
4 Correct 2 ms 528 KB n = 3, 4 is a correct answer
5 Incorrect 2 ms 528 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB n = 4, 80 is a correct answer
2 Correct 2 ms 484 KB n = 9, 110 is a correct answer
3 Correct 2 ms 528 KB n = 4, 21 is a correct answer
4 Correct 2 ms 528 KB n = 3, 4 is a correct answer
5 Incorrect 2 ms 528 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB n = 4, 80 is a correct answer
2 Correct 2 ms 484 KB n = 9, 110 is a correct answer
3 Correct 2 ms 528 KB n = 4, 21 is a correct answer
4 Correct 2 ms 528 KB n = 3, 4 is a correct answer
5 Incorrect 2 ms 528 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB n = 4, 80 is a correct answer
2 Correct 2 ms 484 KB n = 9, 110 is a correct answer
3 Correct 2 ms 528 KB n = 4, 21 is a correct answer
4 Correct 2 ms 528 KB n = 3, 4 is a correct answer
5 Incorrect 2 ms 528 KB n = 2, incorrect answer: jury 62 vs contestant 72
6 Halted 0 ms 0 KB -