Submission #528605

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
5286052022-02-20 17:37:32Alex_tz307Gap (APIO16_gap)C++17
100 / 100
75 ms1952 KiB
#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
long long findGap(int t, int n) {
if (t == 1) {
vector<long long> a(n + 1);
long long l = 0, r = 1e18L;
for (int i = 1; i <= (n + 1) / 2; ++i) {
MinMax(l, r, &a[i], &a[n - i + 1]);
l = a[i] + 1, r = a[n - i + 1] - 1;
}
long long ans = 0;
for (int i = 2; i <= n; ++i) {
ans = max(ans, a[i] - a[i - 1]);
}
return ans;
}
long long first, last;
MinMax(0, 1e18L, &first, &last);
long long buck = (last - first) / (n - 1), ans = 0, prv = first;
for (long long i = first + 1; i <= last; i += buck + 1) {
long long x, y;
MinMax(i, i + buck, &x, &y);
if (x != -1) {
ans = max(ans, x - prv);
prv = y;
}
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...