Submission #390938

#TimeUsernameProblemLanguageResultExecution timeMemory
390938BlagojceGap (APIO16_gap)C++11
59.04 / 100
66 ms2384 KiB
#include <bits/stdc++.h> #define fr(i, n, m) for(int i = (n); i < (m); i ++) #define pb push_back #define st first #define nd second #define pq priority_queue #define all(x) begin(x), end(x) using namespace std; typedef long long ll; typedef long double ld; typedef pair<int,int> pii; const int mxn = 1e5; #include "gap.h" long long findGap(int T, int N) { if(T == 1){ ll lb = -1, rb = 1e18+1; vector<ll> v; while(lb < rb){ ll llb, rrb; MinMax(lb+1, rb-1, &llb, &rrb); if(llb == -1) break; v.pb(llb); v.pb(rrb); lb = llb; rb = rrb; } sort(all(v)); ll ans = 0; fr(i, 0, (int)v.size()-1){ ans = max(ans, v[i+1]-v[i]); } return ans; } ll a1, an; MinMax(0, 1e18, &a1, &an); ll d = (an - a1)/(N-1); ll pr = a1; ll ans = 0; for(int i = 0; a1 + 1 + i*d < an; i++){ ll ai, aj; MinMax(a1+1 + i*d, min(a1 + (i+1)*d, an-1), &ai, &aj); if(ai != -1){ ans = max(ans, ai-pr); pr = aj; } } ans = max(ans, an-pr); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...