# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
101635 | 2019-03-19T05:42:39 Z | asifthegreat | Gap (APIO16_gap) | C++14 | 0 ms | 0 KB |
#include <bits/stdc++.h> #define int long long #define all(a) a.begin(),a.end() using namespace std; vector<int>v; long long findGap(int32_t T,int32_t n) { v.clear(); if(T == 1){ int s = 0,t = 1000000000000000001,mn,mx,sz = 0; while(1){ if(sz >= n)break; MinMax(s,t,&mn,&mx); v.push_back(mn); if(mn != mx){v.push_back(mx);sz++;} s = mn+1; t = mx-1; sz++; } sort(all(v)); int ans = -1; for(int i = 1; i < n;i++){ ans = max(ans,v[i]-v[i-1]); } return ans; } else return 0; }