Submission #1105740

#TimeUsernameProblemLanguageResultExecution timeMemory
1105740mariaclaraGap (APIO16_gap)C++17
100 / 100
36 ms3584 KiB
#include "gap.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; const ll INF = 1e18; #define all(x) x.begin(), x.end() #define sz(x) (int)x.size() #define mk make_pair #define pb push_back #define fr first #define sc second ll findGap(int T, int N) { if(T == 1) { vector<ll> a(N); int l = 0, r = N-1; ll val1 = 0, val2 = INF; while(l <= r) { MinMax(val1, val2, &a[l], &a[r]); val1 = a[l] + 1; val2 = a[r] - 1; l++; r--; } ll ans = 0; for(int i = 1; i < N; i++) ans = max(ans, a[i] - a[i-1]); return ans; } ll at, last; MinMax(0, INF, &at, &last); ll ans = (last-at + N-2)/(N-1), val = at + ans + 1; while(at < last) { ll a, b; MinMax(at+1, val, &a, &b); if(a != -1) { ans = max(ans, a - at); at = b; val = at + ans + 1; continue; } ans++; val += ans; } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...