Submission #106953

#TimeUsernameProblemLanguageResultExecution timeMemory
106953golubGap (APIO16_gap)C++14
0 / 100
68 ms1664 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) { // cout << s << " " << t << "!\n"; askcount++; long long mn = 0, mx = 0; MinMax(s, t, &mn, &mx); return {mn, mx}; } long long findGap(int T, int N) { vector<int> a(N); long long itr1 = 0, itr2 = N - 1; long long l = 0, r = (long long)1e18 + 1; while (itr1 <= itr2) { pii res = ask(l, r); a[itr1++] = res.F; a[itr2--] = res.S; l = res.F + 1; r = res.S - 1; } int best = 0; for (int i = 0; i < N; i++) { // cout << a[i] << " "; if (i) cmax(best, a[i] - a[i - 1]); } // cout << "\n"; // cout << "SCORE = " << askcount << "\n"; return best; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...