Submission #933377

#TimeUsernameProblemLanguageResultExecution timeMemory
933377SmuggingSpunGap (APIO16_gap)C++14
86.31 / 100
49 ms3824 KiB
#include "gap.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; template<class T>void maximize(T& a, T b){ if(a < b){ a = b; } } long long findGap(int T, int n){ ll ans = 0; if(T == 1){ vector<ll>a(n); ll low = 0, high = 1e18; int l = 0, r = n - 1; while(l <= r){ MinMax(low, high, &a[l], &a[r]); low = a[l++] + 1; high = a[r--] - 1; } for(int i = 1; i < n; i++){ maximize(ans, a[i] - a[i - 1]); } } else{ ll a_1, a_n; MinMax(0, 1e18, &a_1, &a_n); ll average = (a_n - a_1 + n - 2) / (n - 1); while(a_1 < a_n){ ll next_value = -1, temp, to = a_1; while(next_value == -1){ MinMax(a_1 + 1, to += average, &next_value, &temp); } maximize(ans, next_value - a_1); a_1 = temp; } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...