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 "gap.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
vector<lint> v;
lint findGap(int t, int n)
{
lint mn=0, mx=1e18;
if (t == 1) {
for (int i=0; i<(n+1)/2; i++) {
MinMax(mn, mx, &mn, &mx);
v.push_back(mn);
v.push_back(mx);
mn++; mx--;
}
} else {
MinMax(mn, mx, &mn, &mx);
v.push_back(mn);
v.push_back(mx);
lint k = (mx-mn+n-2)/(n-1)+1, now = mn, nxt = mn+k;
while (now <= mx) {
lint a, b;
MinMax(now, nxt-1, &a, &b);
now += k; nxt += k;
if (a>=0) v.push_back(a);
if (b>=0) v.push_back(b);
}
}
sort(v.begin(), v.end());
lint res = 0;
for (int i=0; i<v.size()-1; i++) res = max(res, v[i+1] - v[i]);
return res;
}
Compilation message (stderr)
gap.cpp: In function 'lint findGap(int, int)':
gap.cpp:36:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i=0; i<v.size()-1; i++) res = max(res, v[i+1] - v[i]);
^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |