Submission #238815

#TimeUsernameProblemLanguageResultExecution timeMemory
238815balbitGap (APIO16_gap)C++14
100 / 100
76 ms2344 KiB
#include <bits/stdc++.h> #ifndef BALBIT #include "gap.h" #endif // BALBIT using namespace std; #define ll long long #define pii pair<int, int> #define f first #define s second #define SZ(x) (int)(x.size()) #define ALL(x) (x).begin(), (x).end() #define pb push_back #ifdef BALBIT #define bug(...) cerr<<"#"<<__LINE__<<" "<<#__VA_ARGS__<<": ", _do(__VA_ARGS__) template<typename T> void _do(T && x) {cerr<<x<<endl;} template<typename T, typename ...S> void _do(T && x, S&&...y) {cerr<<x<<", "; _do(y...);} #define IOS() #else #define IOS() ios::sync_with_stdio(0), cin.tie(0) #define endl '\n' #define bug(...) #endif // BALBIT const int maxn = 1e6+5; #ifdef BALBIT void MinMax(ll l,ll r,ll *s, ll *t) { bug(l,r); cin>>*s>>*t; } #endif // BALBIT ll findGap(int T, int n) { if (T == 2){ ll s, t; MinMax(0, 1e18, &s, &t); ll gp = (t-s+n-1-1) / (n-1); bug(gp); ll prev = s; ll re = 0; for (ll i = s+1; i < t; i += gp) { ll a, b; MinMax(i,min(i+gp-1,t),&a,&b); if (a == -1) continue; re = max(re, a-prev); prev = b; } return re; } else{ vector<ll> hv; ll L = 0, R= 1e18; ll s=1, t=1; for (int i = 0; i<(n+1)/2; ++i){ MinMax(L,R,&s,&t); hv.pb(s); hv.pb(t); L = s+1; R = t-1; } sort(ALL(hv)); ll re = 0; for (int i = 1; i<SZ(hv); ++i) { re = max(re, hv[i] - hv[i-1]); } return re; } } #ifdef BALBIT signed main(){ IOS(); cout<<findGap(1,4)<<endl; } #endif
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...