제출 #1075822

#제출 시각아이디문제언어결과실행 시간메모리
1075822alexddGap (APIO16_gap)C++17
12.76 / 100
40 ms1136 KiB
#include "gap.h"
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int INF = 1e18;
pair<int,int> qry(int le, int ri)
{
    pair<int,int> aux;
    MinMax(le,ri,&aux.first,&aux.second);
    return aux;
}
long long findGap(int32_t T, int32_t N)
{
    int rez=1;
    pair<int,int> tot = qry(0,INF);
    int cur=tot.first;
    while(tot.second - cur > rez)
    {
        pair<int,int> aux = qry(cur+1,cur+rez);
        if(aux.first!=-1)
        {
            cur = aux.second;
            continue;
        }
        int c=rez;
        while(1)
        {
            c=(c+1)*2;
            aux = qry(cur+1,cur+c);
            if(aux.first!=-1)
            {
                rez = max(rez, aux.first - cur);
                cur = aux.second;
                break;
            }
        }
    }
    return rez;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...