# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
568653 | Deepesson | Gap (APIO16_gap) | C++17 | 75 ms | 8512 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>
#include "gap.h"
void MinMax(long long, long long, long long*, long long*);
using ll = long long;
long long findGap(int T, int N)
{
if(T==2)
return 0;
else {
std::map<ll,bool> mapa;
ll l=-1,r=1e18;++r;
while(mapa.size()!=N){
ll a,b;
if(l+1>r-1)break;
MinMax(l+1,r-1,&a,&b);
if(a!=-1){
mapa[a]=true;
l=a;
}
if(b!=-1){
mapa[b]=true;
r=b;
}
if(a==b&&a==-1)break;
}
ll max=0;
std::vector<ll> vec;
std::sort(vec.begin(),vec.end());
for(auto&x:mapa)vec.push_back(x.first);
for(int i=1;i!=vec.size();++i)max=std::max(max,vec[i]-vec[i-1]);
return max;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |