Submission #172420

#TimeUsernameProblemLanguageResultExecution timeMemory
172420rama_pangGap (APIO16_gap)C++14
70 / 100
82 ms4460 KiB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
using lint = long long;

lint findGap(int T, int N) {
    lint low, high;
    MinMax(0, (lint) 1e18, &low, &high) ;   

    lint BLOCK = ((high - low - 1) / (N - 1)) + 1;

    vector<lint> X;
    X.emplace_back(low);
    for (lint i = low + 1; i < high; i += BLOCK + 1) {
        lint mn, mx;
        MinMax(i, min(i + BLOCK, high - 1), &mn, &mx);
        if (mn != -1 && mx != -1) {
            X.emplace_back(mn);
            X.emplace_back(mx);
        }
    }
    X.emplace_back(high);

    lint res = 0;
    for (int i = 0; i + 1 < X.size(); i++) {
        res = max(res, X[i + 1] - X[i]);
    }
    
    return res;
}

Compilation message (stderr)

gap.cpp: In function 'lint findGap(int, int)':
gap.cpp:25:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i + 1 < X.size(); i++) {
                     ~~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...