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 <iostream>
#include <set>
#include "gap.h"
#define INF 1000000000000000000
using namespace std;
set <long long> s;
long long findGap(int T, int N)
{
long long minimum, maximum;
MinMax(1, INF, &minimum, &maximum);
long long gapLength;
if ((maximum - minimum) % (N - 1) == 0)
gapLength = (maximum - minimum) / (N - 1);
else
gapLength = (maximum - minimum) / (N - 1) + 1;
for (long long i = minimum + 1; i <= maximum - 1; i = i + gapLength)
{
long long val1, val2;
MinMax(i, i + gapLength - 1, &val1, &val2);
s.insert(val1);
s.insert(val2);
}
s.erase(-1);
long long maxGap = 0, last = minimum;
for (auto it : s)
{
maxGap = max(maxGap, it - last);
last = it;
}
return maxGap;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |