This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "gap.h"
using ll = long long;
using namespace std;
long long findGap(int T, int N){
ll pmini = -1, pmaxi = 1e18+1;
vector<ll> ans;
bool ok1 = 0, ok2 = 0;
for (int i=0; i<(N+1)/2; ++i){
long long a,b;
MinMax(pmini+1,pmaxi-1,&a,&b);
if (a != -1 and !ok1) ans.emplace_back(a);
if (b != -1 and a != b and !ok2) ans.emplace_back(b);
if (a != -1) pmini = a;
else ok1 = 1;
if (b != -1) pmaxi = b;
else ok2 = 1;
if (a >= b) break;
}
sort(ans.begin(),ans.end());
ans.erase(unique(ans.begin(),ans.end()));
ll res = 0;
for (int i=1; i<ans.size(); ++i){
res = max(res,ans[i]-ans[i-1]);
}
return res;
}
Compilation message (stderr)
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:24:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
24 | for (int i=1; i<ans.size(); ++i){
| ~^~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |