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"
#define INF 1'000'000'000'000'000'000ll
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
LL ans, C;
LL Min, Max;
vector<LL> V;
long long findGap(int T, int N){
if (T == 1){
LL l=0, r=INF;
for (int i=0; i<N; i+=2){
LL x, y;
MinMax(l, r, &x, &y);
V.push_back(x);
V.push_back(y);
l=x+1, r=y-1;
}
}
else{
MinMax(0, INF, &Min, &Max);
ans = C = (Max-Min+N-2)/(N-1);
LL t = Min;
V.push_back(Min);
while (t+C <= Max){
LL x, y;
MinMax(t+1, t+C, &x, &y);
if (x>=0) V.push_back(x);
if (y>=0) V.push_back(y);
t += C;
}
V.push_back(Max);
}
sort(V.begin(), V.end());
for (int i=0; i<V.size()-1; i++) ans = max(ans, V[i+1]-V[i]);
return ans;
}
Compilation message (stderr)
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:38:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i=0; i<V.size()-1; i++) ans = max(ans, V[i+1]-V[i]);
~^~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |