# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
813016 | Pikachu | Gap (APIO16_gap) | C++17 | 0 ms | 0 KiB |
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>
#define int long long
using namespace std;
template<typename T>
inline bool maxi(T &x, const T &val)
{
if (x < val) return x = val, true;
return false;
}
template<typename T>
inline bool mini(T &x, const T &val)
{
if (x > val) return x = val, true;
return false;
}
const int maxn = 1e5 + 10, oo = 1e18;
int n;
int a[maxn];
int res;
void MinMax(long long s, long long t, long long *mn, long long *mx);
int solve1()
{
int st = 0, en = oo;
int *tmpn = new int(0), *tmpx = new int(oo);
int curst = 1, curen = n;
while (curst <= curen) {
MinMax(st, en, tmpn, tmpx);
a[curst++] = *tmpn;
st = *tmpn + 1;
a[curen--] = *tmpx;
en = *tmpx - 1;
}
for (int i = 1; i < n; i++) {
maxi(res, a[i + 1] - a[i]);
}
return res;
}
int solve2()
{
}
int findGap(int sub, int n)
{
::n = n;
if (sub == 1) return solve1();
else return solve2();
}
#undef int