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 <algorithm>
#include <iostream>
#include <vector>
using namespace std;
long long a[100009]; int res = 0, maxn = 0;
vector<long long>Q;
long long findGap(int T, int N)
{
if (T == 1) {
long long L = 0, R = 1000000000000000000LL, s, t, cnt = 0;
while (cnt < (N + 1) / 2) {
MinMax(L, R, &s, &t);
L = s; R = t;
if (L != -1) { a[cnt + 1] = L; a[N - cnt] = R; }
cnt++; L++; R--;
}
long long maxn = 0;
for (int i = 1; i <= N - 1; i++) maxn = max(maxn, a[i + 1] - a[i]);
return maxn;
}
if (T == 2) {
long long s, t; MinMax(0, 1000000000000000000LL, &s, &t); t++;
long long T = 2 * N;
vector<long long>B; long double L = 1.0L*(t - s) / T;
for (int i = 0; i <= T; i++) B.push_back(s + (long long)(1.0L*L*i));
B[T] = t;
for (int i = 0; i < B.size() - 1; i++) {
MinMax(B[i], B[i + 1] - 1, &s, &t);
//cout << B[i] << " " << B[i + 1] - 1 << " " << s << " " << t << endl;
if (s != -1) {
Q.push_back(s);
Q.push_back(t);
}
}
sort(Q.begin(), Q.end());
Q.erase(unique(Q.begin(), Q.end()), Q.end());
long long maxn = 0;
for (int i = 0; i < Q.size() - 1; i++) maxn = max(maxn, Q[i + 1] - Q[i]);
return maxn;
}
return 0;
}
Compilation message (stderr)
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:33:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < B.size() - 1; i++) {
~~^~~~~~~~~~~~~~
gap.cpp:45:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < Q.size() - 1; i++) maxn = max(maxn, Q[i + 1] - Q[i]);
~~^~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |