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 namespace std;
long long findGap(int T, int N)
{
long long min, maxi;
if (T == 1) {
vector<long long> a;
MinMax(0, (long long)1012345678901234567, &min, &maxi);
for (int i = 0; i < (N-1)/2; i++) {
a.push_back(min);
a.push_back(maxi);
long long temp = min+1;
long long temp2 = maxi-1;
MinMax(temp, temp2, &min, &maxi);
}
if (N%2==0) {
a.push_back(min);
a.push_back(maxi);
}
else {
a.push_back(min);
}
sort(a.begin(), a.end());
long long gap = 0;
for (int i = 1; i < a.size(); i++) {
gap = max(a[i] - a[i-1], gap);
}
return gap;
}
else {
MinMax(0, (long long)1012345678901234567, &min, &maxi);
long long gap = 0;
vector<long long> a;
long long dis = ceil((maxi - min )/((long double)N-1) + 1);
long long min2 = min, max2 = (min + dis);
for (int i = 0; i < N-1; i++) {
MinMax(min2, max2, &min, &maxi);
if (min == maxi && min != -1) {
a.push_back(min);
}
else if (min != maxi) {
a.push_back(min);
a.push_back(maxi);
}
min2 = max2+1;
max2 += dis;
}
for (int i = 1; i < a.size(); i++) {
gap = max(a[i] - a[i-1], gap);
}
return gap;
}
}
Compilation message (stderr)
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:27:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 1; i < a.size(); i++) {
~~^~~~~~~~~~
gap.cpp:50:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 1; i < a.size(); i++) {
~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |