# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
142738 | HellAngel | Gap (APIO16_gap) | C++14 | 94 ms | 3472 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 "gap.h"
#include <bits/stdc++.h>
using namespace std;
long long findGap(int T, int N)
{
long long ans = 0;
vector<long long> vt = {};
long long Max, Min;
MinMax(0, 1e18, &Min, &Max);
if(T == 1)
{
vt.push_back(Max);
vt.push_back(Min);
long long l = 2;
long long r = N - 1;
while(l <= r)
{
long long a, b;
MinMax(Min + 1, Max - 1, &Min, &Max);
vt.push_back(Min);
vt.push_back(Max);
l++;
r--;
}
}
else
{
long long qr = (Max - Min + N - 2) / (N - 1);
ans = qr;
for(long long x = Min; x <= Max ; x += qr + 1)
{
long long xa,xb;
MinMax(x, x + qr, &xa, &xb);
vt.push_back(xa),vt.push_back(xb);
}
}
sort(vt.begin(), vt.end());
for(int i = 1; i < vt.size(); i++) ans = max(ans, vt[i] - vt[i - 1]);
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |