답안 #827233

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
827233 2023-08-16T10:02:34 Z tolbi Shortcut (IOI16_shortcut) C++17
0 / 100
1 ms 304 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#include "shortcut.h"
int c;
int d[3000];
int pref[3000];
pair<ll,bool> pr;
int n;
inline ll query(int l, int r){
    if (l==r) return 0ll;
    if (r<l) swap(l,r);
    return pref[r]-pref[l];
}
inline void dene(int l, int r){
    ll leftside=0;
    ll rightside=0;
    int indi = 0;
    deque<pair<ll,int>> hoaydaaa;
    ll bruh=-1;
    for (int i = 0; i < n; i++){
        if (i){
            while (indi<i){
                if (query(indi,l)+query(i,r)+c<=query(indi,i)){
                    bruh=max(bruh,query(indi,l)+d[indi]);
                    indi++;
                }
                else break;
            }
            ll crr = 0;
            while (hoaydaaa.size()>0){
                ll node = hoaydaaa.back().second;
                if (indi>node){
                    hoaydaaa.pop_back();
                }
                else break;
            }
            if (hoaydaaa.size()>0){
                crr=max(crr,(ll)d[i]+pref[i]+hoaydaaa.back().first);
            }
            if (bruh!=-1){
                crr=max(crr,(ll)d[i]+bruh+c+query(i,r));
            }
            if (i>=r){
                rightside=max(rightside,crr);
            }
            else {
                leftside=max(leftside,crr);
            }
        }
        while (hoaydaaa.size() && hoaydaaa.front().first<=(ll)d[i]-pref[i]){
            hoaydaaa.pop_front();
        }
        hoaydaaa.push_front({(ll)d[i]-pref[i],i});
    }
    pr={max(leftside,rightside),(rightside>leftside)};
};
long long find_shortcut(int _n, std::vector<int> _p, std::vector<int> _d, int _c)
{
    n=_n;
    c=_c;
    pref[0]=0;
    for (int i = 0; i < n-1; i++){
        pref[i+1]=_p[i]+pref[i];
    }
    for (int i = 0; i < n; ++i)
    {
        d[i]=_d[i];
    }
    ll ans = LONG_LONG_MAX;
    for (int l = 0; l < n; l++){
        int ll = l, rr = n-1;
        while (ll<rr){
            int mid = ll+(rr-ll)/2;
            dene(l,mid);
            ans=min(ans,pr.first);
            if (!pr.second){
                rr=mid;
            }
            else {
                ll=mid+1;
            }
        }
        dene(l,ll);
        ans=min(ans,pr.first);
    }
    for (int i = 0; i < n; ++i)
    {
        ans=max(ans,(ll)d[i]);
    }
    return ans;
}
# 결과 실행 시간 메모리 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 1 ms 212 KB n = 4, 21 is a correct answer
4 Correct 0 ms 212 KB n = 3, 4 is a correct answer
5 Correct 1 ms 212 KB n = 2, 62 is a correct answer
6 Correct 0 ms 212 KB n = 2, 3 is a correct answer
7 Correct 0 ms 304 KB n = 3, 29 is a correct answer
8 Correct 0 ms 300 KB n = 2, 3 is a correct answer
9 Correct 0 ms 304 KB n = 2, 3 is a correct answer
10 Correct 0 ms 212 KB n = 2, 2000000001 is a correct answer
11 Correct 0 ms 212 KB n = 2, 3000000000 is a correct answer
12 Correct 1 ms 212 KB n = 3, 3000000000 is a correct answer
13 Correct 1 ms 212 KB n = 3, 3000000000 is a correct answer
14 Incorrect 1 ms 296 KB n = 4, incorrect answer: jury 3000000001 vs contestant 3000000000
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 1 ms 212 KB n = 4, 21 is a correct answer
4 Correct 0 ms 212 KB n = 3, 4 is a correct answer
5 Correct 1 ms 212 KB n = 2, 62 is a correct answer
6 Correct 0 ms 212 KB n = 2, 3 is a correct answer
7 Correct 0 ms 304 KB n = 3, 29 is a correct answer
8 Correct 0 ms 300 KB n = 2, 3 is a correct answer
9 Correct 0 ms 304 KB n = 2, 3 is a correct answer
10 Correct 0 ms 212 KB n = 2, 2000000001 is a correct answer
11 Correct 0 ms 212 KB n = 2, 3000000000 is a correct answer
12 Correct 1 ms 212 KB n = 3, 3000000000 is a correct answer
13 Correct 1 ms 212 KB n = 3, 3000000000 is a correct answer
14 Incorrect 1 ms 296 KB n = 4, incorrect answer: jury 3000000001 vs contestant 3000000000
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 1 ms 212 KB n = 4, 21 is a correct answer
4 Correct 0 ms 212 KB n = 3, 4 is a correct answer
5 Correct 1 ms 212 KB n = 2, 62 is a correct answer
6 Correct 0 ms 212 KB n = 2, 3 is a correct answer
7 Correct 0 ms 304 KB n = 3, 29 is a correct answer
8 Correct 0 ms 300 KB n = 2, 3 is a correct answer
9 Correct 0 ms 304 KB n = 2, 3 is a correct answer
10 Correct 0 ms 212 KB n = 2, 2000000001 is a correct answer
11 Correct 0 ms 212 KB n = 2, 3000000000 is a correct answer
12 Correct 1 ms 212 KB n = 3, 3000000000 is a correct answer
13 Correct 1 ms 212 KB n = 3, 3000000000 is a correct answer
14 Incorrect 1 ms 296 KB n = 4, incorrect answer: jury 3000000001 vs contestant 3000000000
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 1 ms 212 KB n = 4, 21 is a correct answer
4 Correct 0 ms 212 KB n = 3, 4 is a correct answer
5 Correct 1 ms 212 KB n = 2, 62 is a correct answer
6 Correct 0 ms 212 KB n = 2, 3 is a correct answer
7 Correct 0 ms 304 KB n = 3, 29 is a correct answer
8 Correct 0 ms 300 KB n = 2, 3 is a correct answer
9 Correct 0 ms 304 KB n = 2, 3 is a correct answer
10 Correct 0 ms 212 KB n = 2, 2000000001 is a correct answer
11 Correct 0 ms 212 KB n = 2, 3000000000 is a correct answer
12 Correct 1 ms 212 KB n = 3, 3000000000 is a correct answer
13 Correct 1 ms 212 KB n = 3, 3000000000 is a correct answer
14 Incorrect 1 ms 296 KB n = 4, incorrect answer: jury 3000000001 vs contestant 3000000000
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 1 ms 212 KB n = 4, 21 is a correct answer
4 Correct 0 ms 212 KB n = 3, 4 is a correct answer
5 Correct 1 ms 212 KB n = 2, 62 is a correct answer
6 Correct 0 ms 212 KB n = 2, 3 is a correct answer
7 Correct 0 ms 304 KB n = 3, 29 is a correct answer
8 Correct 0 ms 300 KB n = 2, 3 is a correct answer
9 Correct 0 ms 304 KB n = 2, 3 is a correct answer
10 Correct 0 ms 212 KB n = 2, 2000000001 is a correct answer
11 Correct 0 ms 212 KB n = 2, 3000000000 is a correct answer
12 Correct 1 ms 212 KB n = 3, 3000000000 is a correct answer
13 Correct 1 ms 212 KB n = 3, 3000000000 is a correct answer
14 Incorrect 1 ms 296 KB n = 4, incorrect answer: jury 3000000001 vs contestant 3000000000
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 1 ms 212 KB n = 4, 21 is a correct answer
4 Correct 0 ms 212 KB n = 3, 4 is a correct answer
5 Correct 1 ms 212 KB n = 2, 62 is a correct answer
6 Correct 0 ms 212 KB n = 2, 3 is a correct answer
7 Correct 0 ms 304 KB n = 3, 29 is a correct answer
8 Correct 0 ms 300 KB n = 2, 3 is a correct answer
9 Correct 0 ms 304 KB n = 2, 3 is a correct answer
10 Correct 0 ms 212 KB n = 2, 2000000001 is a correct answer
11 Correct 0 ms 212 KB n = 2, 3000000000 is a correct answer
12 Correct 1 ms 212 KB n = 3, 3000000000 is a correct answer
13 Correct 1 ms 212 KB n = 3, 3000000000 is a correct answer
14 Incorrect 1 ms 296 KB n = 4, incorrect answer: jury 3000000001 vs contestant 3000000000
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 1 ms 212 KB n = 4, 21 is a correct answer
4 Correct 0 ms 212 KB n = 3, 4 is a correct answer
5 Correct 1 ms 212 KB n = 2, 62 is a correct answer
6 Correct 0 ms 212 KB n = 2, 3 is a correct answer
7 Correct 0 ms 304 KB n = 3, 29 is a correct answer
8 Correct 0 ms 300 KB n = 2, 3 is a correct answer
9 Correct 0 ms 304 KB n = 2, 3 is a correct answer
10 Correct 0 ms 212 KB n = 2, 2000000001 is a correct answer
11 Correct 0 ms 212 KB n = 2, 3000000000 is a correct answer
12 Correct 1 ms 212 KB n = 3, 3000000000 is a correct answer
13 Correct 1 ms 212 KB n = 3, 3000000000 is a correct answer
14 Incorrect 1 ms 296 KB n = 4, incorrect answer: jury 3000000001 vs contestant 3000000000
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 1 ms 212 KB n = 4, 21 is a correct answer
4 Correct 0 ms 212 KB n = 3, 4 is a correct answer
5 Correct 1 ms 212 KB n = 2, 62 is a correct answer
6 Correct 0 ms 212 KB n = 2, 3 is a correct answer
7 Correct 0 ms 304 KB n = 3, 29 is a correct answer
8 Correct 0 ms 300 KB n = 2, 3 is a correct answer
9 Correct 0 ms 304 KB n = 2, 3 is a correct answer
10 Correct 0 ms 212 KB n = 2, 2000000001 is a correct answer
11 Correct 0 ms 212 KB n = 2, 3000000000 is a correct answer
12 Correct 1 ms 212 KB n = 3, 3000000000 is a correct answer
13 Correct 1 ms 212 KB n = 3, 3000000000 is a correct answer
14 Incorrect 1 ms 296 KB n = 4, incorrect answer: jury 3000000001 vs contestant 3000000000
15 Halted 0 ms 0 KB -