# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
882300 | 2023-12-03T03:26:07 Z | ono_de206 | Gap (APIO16_gap) | C++14 | 0 ms | 0 KB |
#include "gap.h" #include<bits/stdc++.h> using namespace std; #define in insert #define all(x) x.begin(),x.end() #define pb push_back #define eb emplace_back #define ff first #define ss second // #define int long long typedef long long ll; typedef vector<int> vi; typedef set<int> si; typedef multiset<int> msi; typedef pair<int, int> pii; typedef vector<pii> vpii; long long findGap(int T, int N) { long long *qn, *qx; auto ask = [&](long long l, long long r) -> void { assert(l <= r); MinMax(l, r, &qn, &qx); }; long long sus1 = 0, sus2 = (long long)1e18; ask(sus1, sus2); long long mn = *qn, mx = *qx, ans = 0; long long d = (mx - mn) / N; long long ls = mn, l = mn + 1; while(l <= mx) { long long r = l + d - 1; ask(l, r); if(*qn != -1) { ans = max(ans, *qn - ls); ls = *qx; } l = r + 1; } return ans; }