Submission #902548

# Submission time Handle Problem Language Result Execution time Memory
902548 2024-01-10T16:28:10 Z abcvuitunggio Shortcut (IOI16_shortcut) C++17
0 / 100
1 ms 600 KB
#include "shortcut.h"
#include <bits/stdc++.h>
using namespace std;
const long long INF=1LL<<51;
const int mxn=1000001;
long long s[mxn];
long long find_shortcut(int n, vector <int> l, vector <int> d, int c){
    for (int i=1;i<n;i++)
        s[i]=s[i-1]+l[i-1];
    s[n]=INF;
    long long lo=0,hi=INF,kq=-1;
    while (lo<=hi){
        long long mid=(lo+hi)>>1,mnx=-INF,mxx=INF,mny=-INF,mxy=INF,x=-INF,y=INF;
        deque <pair <int, int>> q;
        for (int i=0;i<n;i++){
            while (!q.empty()&&s[i]+d[i]-q.front().first>mid){
                int i=q.front().second;
                x=max(x,s[i]+d[i]);
                y=min(x,s[i]-d[i]);
                q.pop_front();
            }
            while (!q.empty()&&q.back().first>=s[i]-d[i])
                q.pop_back();
            q.push_back({s[i]-d[i],i});
            mnx=max(mnx,s[i]+d[i]+c-mid+x);
            mxx=min(mxx,s[i]-d[i]-c+mid+y);
            mny=max(mny,x+c-mid-s[i]+d[i]);
            mxy=min(mxy,y-c+mid-s[i]-d[i]);
        }
        int tmp=0,j=n,ch=0;
        for (int i=0;i<n;i++){
            long long l=max(mnx-s[i],s[i]-mxy);
            if (mnx-s[i]<s[i]-mxy&&!tmp){
                j=0;
                tmp=1;
            }
            if (tmp)
                while (j<n&&s[j]<l)
                    j++;
            else{
                while (j>=0&&s[j]>=l)
                    j--;
                j++;
            }
            if (j<n&&s[j]<=min(mxx-s[i],s[i]-mny)){
                ch=1;
                break;
            }
        }
        if (ch){
            kq=mid;
            hi=mid-1;
        }
        else
            lo=mid+1;
    }
    return kq;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB n = 4, 80 is a correct answer
2 Correct 0 ms 348 KB n = 9, 110 is a correct answer
3 Correct 1 ms 348 KB n = 4, 21 is a correct answer
4 Correct 0 ms 348 KB n = 3, 4 is a correct answer
5 Correct 1 ms 348 KB n = 2, 62 is a correct answer
6 Correct 1 ms 348 KB n = 2, 3 is a correct answer
7 Correct 0 ms 348 KB n = 3, 29 is a correct answer
8 Correct 0 ms 348 KB n = 2, 3 is a correct answer
9 Correct 1 ms 344 KB n = 2, 3 is a correct answer
10 Correct 1 ms 348 KB n = 2, 2000000001 is a correct answer
11 Correct 0 ms 348 KB n = 2, 3000000000 is a correct answer
12 Correct 1 ms 348 KB n = 3, 3000000000 is a correct answer
13 Correct 1 ms 348 KB n = 3, 3000000000 is a correct answer
14 Correct 0 ms 348 KB n = 4, 3000000001 is a correct answer
15 Correct 0 ms 348 KB n = 4, 4000000000 is a correct answer
16 Correct 1 ms 600 KB n = 5, 4000000000 is a correct answer
17 Incorrect 0 ms 348 KB n = 10, incorrect answer: jury 1000000343 vs contestant 1000000156
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB n = 4, 80 is a correct answer
2 Correct 0 ms 348 KB n = 9, 110 is a correct answer
3 Correct 1 ms 348 KB n = 4, 21 is a correct answer
4 Correct 0 ms 348 KB n = 3, 4 is a correct answer
5 Correct 1 ms 348 KB n = 2, 62 is a correct answer
6 Correct 1 ms 348 KB n = 2, 3 is a correct answer
7 Correct 0 ms 348 KB n = 3, 29 is a correct answer
8 Correct 0 ms 348 KB n = 2, 3 is a correct answer
9 Correct 1 ms 344 KB n = 2, 3 is a correct answer
10 Correct 1 ms 348 KB n = 2, 2000000001 is a correct answer
11 Correct 0 ms 348 KB n = 2, 3000000000 is a correct answer
12 Correct 1 ms 348 KB n = 3, 3000000000 is a correct answer
13 Correct 1 ms 348 KB n = 3, 3000000000 is a correct answer
14 Correct 0 ms 348 KB n = 4, 3000000001 is a correct answer
15 Correct 0 ms 348 KB n = 4, 4000000000 is a correct answer
16 Correct 1 ms 600 KB n = 5, 4000000000 is a correct answer
17 Incorrect 0 ms 348 KB n = 10, incorrect answer: jury 1000000343 vs contestant 1000000156
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB n = 4, 80 is a correct answer
2 Correct 0 ms 348 KB n = 9, 110 is a correct answer
3 Correct 1 ms 348 KB n = 4, 21 is a correct answer
4 Correct 0 ms 348 KB n = 3, 4 is a correct answer
5 Correct 1 ms 348 KB n = 2, 62 is a correct answer
6 Correct 1 ms 348 KB n = 2, 3 is a correct answer
7 Correct 0 ms 348 KB n = 3, 29 is a correct answer
8 Correct 0 ms 348 KB n = 2, 3 is a correct answer
9 Correct 1 ms 344 KB n = 2, 3 is a correct answer
10 Correct 1 ms 348 KB n = 2, 2000000001 is a correct answer
11 Correct 0 ms 348 KB n = 2, 3000000000 is a correct answer
12 Correct 1 ms 348 KB n = 3, 3000000000 is a correct answer
13 Correct 1 ms 348 KB n = 3, 3000000000 is a correct answer
14 Correct 0 ms 348 KB n = 4, 3000000001 is a correct answer
15 Correct 0 ms 348 KB n = 4, 4000000000 is a correct answer
16 Correct 1 ms 600 KB n = 5, 4000000000 is a correct answer
17 Incorrect 0 ms 348 KB n = 10, incorrect answer: jury 1000000343 vs contestant 1000000156
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB n = 4, 80 is a correct answer
2 Correct 0 ms 348 KB n = 9, 110 is a correct answer
3 Correct 1 ms 348 KB n = 4, 21 is a correct answer
4 Correct 0 ms 348 KB n = 3, 4 is a correct answer
5 Correct 1 ms 348 KB n = 2, 62 is a correct answer
6 Correct 1 ms 348 KB n = 2, 3 is a correct answer
7 Correct 0 ms 348 KB n = 3, 29 is a correct answer
8 Correct 0 ms 348 KB n = 2, 3 is a correct answer
9 Correct 1 ms 344 KB n = 2, 3 is a correct answer
10 Correct 1 ms 348 KB n = 2, 2000000001 is a correct answer
11 Correct 0 ms 348 KB n = 2, 3000000000 is a correct answer
12 Correct 1 ms 348 KB n = 3, 3000000000 is a correct answer
13 Correct 1 ms 348 KB n = 3, 3000000000 is a correct answer
14 Correct 0 ms 348 KB n = 4, 3000000001 is a correct answer
15 Correct 0 ms 348 KB n = 4, 4000000000 is a correct answer
16 Correct 1 ms 600 KB n = 5, 4000000000 is a correct answer
17 Incorrect 0 ms 348 KB n = 10, incorrect answer: jury 1000000343 vs contestant 1000000156
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB n = 4, 80 is a correct answer
2 Correct 0 ms 348 KB n = 9, 110 is a correct answer
3 Correct 1 ms 348 KB n = 4, 21 is a correct answer
4 Correct 0 ms 348 KB n = 3, 4 is a correct answer
5 Correct 1 ms 348 KB n = 2, 62 is a correct answer
6 Correct 1 ms 348 KB n = 2, 3 is a correct answer
7 Correct 0 ms 348 KB n = 3, 29 is a correct answer
8 Correct 0 ms 348 KB n = 2, 3 is a correct answer
9 Correct 1 ms 344 KB n = 2, 3 is a correct answer
10 Correct 1 ms 348 KB n = 2, 2000000001 is a correct answer
11 Correct 0 ms 348 KB n = 2, 3000000000 is a correct answer
12 Correct 1 ms 348 KB n = 3, 3000000000 is a correct answer
13 Correct 1 ms 348 KB n = 3, 3000000000 is a correct answer
14 Correct 0 ms 348 KB n = 4, 3000000001 is a correct answer
15 Correct 0 ms 348 KB n = 4, 4000000000 is a correct answer
16 Correct 1 ms 600 KB n = 5, 4000000000 is a correct answer
17 Incorrect 0 ms 348 KB n = 10, incorrect answer: jury 1000000343 vs contestant 1000000156
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB n = 4, 80 is a correct answer
2 Correct 0 ms 348 KB n = 9, 110 is a correct answer
3 Correct 1 ms 348 KB n = 4, 21 is a correct answer
4 Correct 0 ms 348 KB n = 3, 4 is a correct answer
5 Correct 1 ms 348 KB n = 2, 62 is a correct answer
6 Correct 1 ms 348 KB n = 2, 3 is a correct answer
7 Correct 0 ms 348 KB n = 3, 29 is a correct answer
8 Correct 0 ms 348 KB n = 2, 3 is a correct answer
9 Correct 1 ms 344 KB n = 2, 3 is a correct answer
10 Correct 1 ms 348 KB n = 2, 2000000001 is a correct answer
11 Correct 0 ms 348 KB n = 2, 3000000000 is a correct answer
12 Correct 1 ms 348 KB n = 3, 3000000000 is a correct answer
13 Correct 1 ms 348 KB n = 3, 3000000000 is a correct answer
14 Correct 0 ms 348 KB n = 4, 3000000001 is a correct answer
15 Correct 0 ms 348 KB n = 4, 4000000000 is a correct answer
16 Correct 1 ms 600 KB n = 5, 4000000000 is a correct answer
17 Incorrect 0 ms 348 KB n = 10, incorrect answer: jury 1000000343 vs contestant 1000000156
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB n = 4, 80 is a correct answer
2 Correct 0 ms 348 KB n = 9, 110 is a correct answer
3 Correct 1 ms 348 KB n = 4, 21 is a correct answer
4 Correct 0 ms 348 KB n = 3, 4 is a correct answer
5 Correct 1 ms 348 KB n = 2, 62 is a correct answer
6 Correct 1 ms 348 KB n = 2, 3 is a correct answer
7 Correct 0 ms 348 KB n = 3, 29 is a correct answer
8 Correct 0 ms 348 KB n = 2, 3 is a correct answer
9 Correct 1 ms 344 KB n = 2, 3 is a correct answer
10 Correct 1 ms 348 KB n = 2, 2000000001 is a correct answer
11 Correct 0 ms 348 KB n = 2, 3000000000 is a correct answer
12 Correct 1 ms 348 KB n = 3, 3000000000 is a correct answer
13 Correct 1 ms 348 KB n = 3, 3000000000 is a correct answer
14 Correct 0 ms 348 KB n = 4, 3000000001 is a correct answer
15 Correct 0 ms 348 KB n = 4, 4000000000 is a correct answer
16 Correct 1 ms 600 KB n = 5, 4000000000 is a correct answer
17 Incorrect 0 ms 348 KB n = 10, incorrect answer: jury 1000000343 vs contestant 1000000156
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB n = 4, 80 is a correct answer
2 Correct 0 ms 348 KB n = 9, 110 is a correct answer
3 Correct 1 ms 348 KB n = 4, 21 is a correct answer
4 Correct 0 ms 348 KB n = 3, 4 is a correct answer
5 Correct 1 ms 348 KB n = 2, 62 is a correct answer
6 Correct 1 ms 348 KB n = 2, 3 is a correct answer
7 Correct 0 ms 348 KB n = 3, 29 is a correct answer
8 Correct 0 ms 348 KB n = 2, 3 is a correct answer
9 Correct 1 ms 344 KB n = 2, 3 is a correct answer
10 Correct 1 ms 348 KB n = 2, 2000000001 is a correct answer
11 Correct 0 ms 348 KB n = 2, 3000000000 is a correct answer
12 Correct 1 ms 348 KB n = 3, 3000000000 is a correct answer
13 Correct 1 ms 348 KB n = 3, 3000000000 is a correct answer
14 Correct 0 ms 348 KB n = 4, 3000000001 is a correct answer
15 Correct 0 ms 348 KB n = 4, 4000000000 is a correct answer
16 Correct 1 ms 600 KB n = 5, 4000000000 is a correct answer
17 Incorrect 0 ms 348 KB n = 10, incorrect answer: jury 1000000343 vs contestant 1000000156
18 Halted 0 ms 0 KB -