Submission #119108

#TimeUsernameProblemLanguageResultExecution timeMemory
119108Charis02Gap (APIO16_gap)C++14
70 / 100
56 ms1152 KiB
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include "gap.h"
#define ll long long
#define MAXV 1e18

using namespace std;
long long solve1(int n)
{
    return 2;
}

long long findGap(int T, int N)
{
    if(T == 1)
        return solve1(N);

    long long a,b;
    MinMax(0LL,MAXV,&a,&b);
    ll dif = (b-a)/(N-1)-2;
    ll k = 1;

    while(a < b)
    {
        ll w,x;
        //cout << a << " " << b << " " << call_count << " " << dif << endl;
        MinMax(a+1,a+dif*k,&x,&w);

        if(w == -1)
        {
            k++;
            continue;
        }

        if(k != 1)
            dif = max(dif,x-a);

        k=1;
        a = w;
    }

    return dif;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...