Submission #47963

#TimeUsernameProblemLanguageResultExecution timeMemory
479633zpGap (APIO16_gap)C++14
70 / 100
72 ms2640 KiB
#include "gap.h" #define ll long long #include<bits/stdc++.h> using namespace std; long long findGap(int T, int N) { if(T == 1){ ll s=-1, t=1e18+1; vector<ll> v; for(int i= 0; i < (N+1)/2; i++){ MinMax(s+1, t-1, &s, &t); if(s == -1) break; else v.push_back(s),v.push_back(t); } sort(v.begin(),v.end()); ll ans = 0; for(int i= 1; i < v.size(); i++) ans=max(ans, v[i]-v[i-1]); return ans; } ll s, t; MinMax(0, 1e18, &s, &t); ll L = t - s; ll d = (L+N-2) / (N - 1); ll ans = d; d++; ll x = s; while(x != t){ ll p, q; if(x + d >= t) break; MinMax(x + 1, x + d, &p , &q); if(q != -1) { ans = max(ans, x - p); x = q; continue; } int w = 2; while(1){ MinMax(x + 1,min( x + w * d, (ll)1e18),&p , &q); if(q == -1) {w++; continue;} ans = max(ans, p - x); d = ans; x = q; break; } } return ans; }

Compilation message (stderr)

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:17:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i= 1; i < v.size(); i++)
                       ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...