Submission #390964

#TimeUsernameProblemLanguageResultExecution timeMemory
390964BlagojceGap (APIO16_gap)C++11
100 / 100
65 ms2236 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 = 0, rb = (1e18); vector<ll> v; fr(i, 0, (int)((N+1)/2)){ ll llb, rrb; MinMax(lb, rb, &llb, &rrb); if(llb == -1) break; v.pb(llb); v.pb(rrb); lb = llb+1; rb = rrb-1; } 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 - 2)/(N-1); ll pr = a1; ll ans = d; for(ll 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...