Submission #282589

#TimeUsernameProblemLanguageResultExecution timeMemory
282589AaronNaiduGap (APIO16_gap)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll findGap(ll t, ll n) {
    vector<ll> v;
    ll leftPointer = 0;
    ll rightPointer = 1000000000000000000;
    ll mn = 0;
    ll mx = 0;
    while (v.size() < n)
    {
        MinMax(leftPointer, rightPointer, &mn, &mx);
        v.push_back(mn);
        v.push_back(mx);
        leftPointer = mn+1;
        rightPointer = mx-1;
    }
    sort(v.begin(), v.end());
    ll maxDiff = 0;
    for (int i = 1; i < v.size(); i++)
    {
        maxDiff = max(maxDiff, v[i]-v[i+1]);
    }
    return maxDiff;
}

Compilation message (stderr)

gap.cpp: In function 'll findGap(ll, ll)':
gap.cpp:11:21: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   11 |     while (v.size() < n)
      |            ~~~~~~~~~^~~
gap.cpp:13:9: error: 'MinMax' was not declared in this scope
   13 |         MinMax(leftPointer, rightPointer, &mn, &mx);
      |         ^~~~~~
gap.cpp:21:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     for (int i = 1; i < v.size(); i++)
      |                     ~~^~~~~~~~~~