제출 #1214922

#제출 시각아이디문제언어결과실행 시간메모리
1214922omsincoconutGap (APIO16_gap)C++17
53.51 / 100
46 ms3260 KiB
#include "gap.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; const ll MAXVAL = 1e18; pair<ll, ll> query(ll l, ll r) { ll a, b; MinMax(l, r, &a, &b); return make_pair(a, b); } ll findGap(int T, int N) { auto [mi, mx] = query(0, MAXVAL); ll query_range = (mx-mi+N)/N; vector<pair<ll, ll>> ranges; for (ll lb = mi; lb <= mx; lb += query_range) { auto [a, b] = query(lb, lb+query_range-1); if (a != -1) ranges.emplace_back(a, b); } ll ans = 0; for (int i = 0; i < ranges.size(); i++) { ans = max(ans, ranges[i].second - ranges[i].first); if (i > 0) ans = max(ans, ranges[i].first - ranges[i-1].second); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...