Submission #106963

#TimeUsernameProblemLanguageResultExecution timeMemory
106963golubGap (APIO16_gap)C++14
30 / 100
71 ms2424 KiB
#include "gap.h" #include<bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define F first #define S second #define pb push_back #define pii pair<long long, long long> #define len(x) (long long)x.size() template<typename A, typename B> bool cmax(A &a, const B &b) { if (a < b) { a = b; return true; } return false; } template<typename A, typename B> bool cmin(A &a, const B &b) { if (a > b) { a = b; return true; } return false; } int askcount = 0; pii ask(long long s, long long t) { askcount++; long long mn = 0, mx = 0; MinMax(s, t, &mn, &mx); return {mn, mx}; } long long findGap(int T, int N) { vector<long long> a(N); long long itr1 = 0, itr2 = N - 1; long long l = -1, r = (long long)1e18 + 1; while (itr1 <= itr2) { pii res = ask(l, r); assert(res.F != -1); assert(res.S != -1); a[itr1++] = res.F; a[itr2--] = res.S; l = res.F + 1; r = res.S - 1; } long long best = -1; sort(all(a)); // for (auto x: a) cout << x << "\n"; for (int i = 0; i < N - 1; i++) { cmax(best, a[i + 1] - a[i]); } return best; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...