# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
629638 | Cyber_Wolf | Gap (APIO16_gap) | C++14 | 22 ms | 1096 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.
//Contest: APIO 16 Problem 3
//Problem Name: Gap
#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
long long findGap(int subtask, int n)
{
vector<long long> v1, v2;
long long first = 0, last = 1e18;
for(int i = 0; i < n; i++)
{
long long mnm, mxm;
MinMax(first, last, &mnm, &mxm);
v1.push_back(mnm);
if(first >= last) break;
if(mnm == mxm) break;
v2.push_back(mxm);
last = mnm+1;
first = mxm-1;
}
long long ans = 0;
for(int i = 1; i < v1.size(); i++) ans = max(ans, v1[i]-v1[i-1]);
if(v2.size())
{
ans = max(ans, v2.front()-v1.back());
}
for(int i = 1; i < v2.size(); i++)
{
ans = max(ans, v2[i]-v2[i-1]);
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |