Submission #1075777

#TimeUsernameProblemLanguageResultExecution timeMemory
1075777alexddGap (APIO16_gap)C++17
0 / 100
36 ms1112 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)
{
    if(N<=10)
        return 1;
    int rez=1;
    pair<int,int> tot = qry(0,INF);
    int cur=tot.first;
    while(cur+rez+1 < tot.second)
    {
        pair<int,int> aux = qry(cur+1,cur+rez);
        if(aux.first!=-1)
        {
            cur = aux.second;
            continue;
        }
        int c=rez;
        while(1)
        {
            c=c*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...