Submission #228114

#TimeUsernameProblemLanguageResultExecution timeMemory
228114eggag32Gap (APIO16_gap)C++17
30 / 100
62 ms1280 KiB
#pragma GCC optimize ("O3") #pragma GCC target ("sse4") #include <bits/stdc++.h> #include "gap.h" using namespace std; typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef pair<int, int> pi; #define debug(x) cerr << #x << ": " << x << endl; #define debug2(x, y) debug(x) debug(y); #define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++) #define rep(i, a) for(int i = 0; i < (int)(a); i++) #define all(v) v.begin(), v.end() #define mp make_pair #define pb push_back #define lb lower_bound #define ub upper_bound #define fi first #define se second #define sq(x) ((x) * (x)) template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); } ll findGap(int t, int n){ if(t == 1){ ll l = 0, r = 1e18; ll mn = 0, mx = 0; MinMax(l, r, &mn, &mx); l = mn, r = mx; int cnt = 0; if(l != r) cnt = 2; else cnt = 1; ll ans = 0; while(cnt < n){ MinMax(l + 1, r - 1, &mn, &mx); if(mn == -1) break; ans = max({mn - l, ans, r - mx}); l = mn, r = mx; if(l == r) cnt++; else cnt += 2; } ans = max(ans, r - l); return ans; } else{ ll l = 0, r = 1e18; ll mn = 0, mx = 0; MinMax(l, r, &mn, &mx); l = mn, r = mx; int cnt = 0; if(l != r) cnt = 2; else cnt = 1; ll ans = 0; while(cnt < n){ MinMax(l + 1, r - 1, &mn, &mx); if(mn == -1) break; ans = max({mn - l, ans, r - mx}); l = mn, r = mx; if(l == r) cnt++; else cnt += 2; } ans = max(ans, r - l); return ans; } } /* Things to look out for: - Integer overflows - Array bounds - Special cases Be careful! */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...