Submission #668329

#TimeUsernameProblemLanguageResultExecution timeMemory
668329birthdaycakeGap (APIO16_gap)C++17
0 / 100
54 ms3284 KiB
#include "gap.h"
#include<bits/stdc++.h>
using namespace std;


long long findGap(int T, int N){
    long long l = 0, r = 0, mn = 0, mx = 0;
    MinMax(1, 1000000000000000000, &mn, &mx);
    l = mn; r = mx;
    long long sz = (r - l + 1) / (N - 1), j = 0;
    vector<pair<long long,long>>d;
    for(j = l; j <= r; j += sz+1){
        MinMax(j, j + sz, &mn, &mx);
        d.push_back({mn, mx});
    }
    MinMax(j, r, &mn, &mx);
    d.push_back({mn, mx});
    long long ans = sz;
    mx = d[0].second;
    for(int i = 1; i < d.size(); i++){
        if(d[i].first != -1){
            ans = max(ans, d[i].first - mx);
            mx = d[i].second;
        }
        
    }
    return ans;
}

Compilation message (stderr)

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:20:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for(int i = 1; i < d.size(); i++){
      |                    ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...