제출 #228118

#제출 시각아이디문제언어결과실행 시간메모리
228118eggag32Gap (APIO16_gap)C++17
30 / 100
1532 ms1292 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 = 0LL; while(cnt < n){ MinMax(l + 1, r - 1, &mn, &mx); 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 low = -1; //our current best ll ans = 0LL; ll mxn = 0LL, prev = 0LL; MinMax(0LL, (ll)1e18, &prev, &mxn); repn(i, 1, n){ ll l = prev + 1, r = mxn; while(l < r){ ll mid = (l + r) / 2; ll mn = 0LL, mx = 0LL; MinMax(prev + 1, mid, &mn, &mx); if(mn == -1) l = mid + 1; else r = mid; } ans = max(ans, l - prev); prev = l; } return ans; } } /* Things to look out for: - Integer overflows - Array bounds - Special cases Be careful! */

컴파일 시 표준 에러 (stderr) 메시지

gap.cpp: In function 'll findGap(int, int)':
gap.cpp:46:6: warning: unused variable 'low' [-Wunused-variable]
   ll low = -1; //our current best
      ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...