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>
typedef long long ll;
using namespace std;
long long findGap(int T, int N) {
if(T == 1) {
vector<ll> nums(N);
ll a, b, x, y, i = 0;
a = 0, b = (long long)1000000000000000000LL;
while(i * 2 < N) {
MinMax(a, b, &x, &y);
nums[i] = x;
nums[N - i - 1] = y;
i++; a = x + 1; b = y - 1;
}
ll ans = 0;
for(int i = 1; i < N; i++) {
ans = max(ans, nums[i] - nums[i-1]);
}
return ans;
}
if(T == 2) {
ll l, r;
MinMax(0, (ll)1e18, &l, &r);
ll siz = (r - l);
ll x = siz / N, y = (siz + N - 1) / N, a, b;
ll i = N;
while(x * i + y * (N - i) != siz) {
i--;
if(i == -1) {
while(true) {}
}
}
ll j = N - i;
ll ans = y;
ll g = l;
vector<ll> nums;
nums.push_back(l);
while(i--) {
MinMax(g, g + x, &a, &b);
g += x;
if(a == -1) continue;
nums.push_back(a);
nums.push_back(b);
}
while(j--) {
MinMax(g, g + y, &a, &b);
g += y;
if(a == -1) continue;
nums.push_back(a);
nums.push_back(b);
}
for(int i = 1; i < nums.size(); i++) {
ans = max(ans, nums[i] - nums[i-1]);
}
return ans;
}
return 0;
}
Compilation message (stderr)
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:55:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
55 | for(int i = 1; i < nums.size(); i++) {
| ~~^~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |