제출 #553174

#제출 시각아이디문제언어결과실행 시간메모리
553174fcmalkcinGap (APIO16_gap)C++17
53.51 / 100
54 ms2640 KiB
#include "gap.h" #include<bits/stdc++.h> using namespace std; #define ll long long #define pll pair<ll,ll> #define ff first #define ss second //#define endl "\n" #define pb push_back #define F(i,a,b) for(ll i=a;i<=b;i++) const ll maxn=1e3+5e2+100; const ll base=3e18; const ll mod= 1e9+7 ; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); ll findGap(int t,int n) { if (t==1) { ll l=-1,h=1e18; h++; // cout <<h<<endl; vector<ll> vt; vector<ll> vt1; ll mn,mx; ll res=0; cout <<l<<" "<<h<<endl; for (int i=1; i<=(n+1)/2; i++) { MinMax(l+1,h-1,&mn,&mx); vt.pb(mn); vt1.pb(mx); l=mn; h=mx; } reverse(vt1.begin(),vt1.end()); for (auto to:vt1) vt.pb(to); for (int i=1; i<(ll)vt.size(); i++) res=max(res,vt[i]-vt[i-1]); return res; } else { ll mn,mx; MinMax(0,1e18,&mn,&mx); ll len=mx-mn; ll pt=mx; ll h=(len+n-1)/(n); h--; ll l=mn; ll pre=base; ll res=0; while (1) { MinMax(l,l+h,&mn,&mx); l+=(h+1); if (mn!=-1) { res=max(res,mn-pre); pre=mx; if (mx==pt) { break; } } else { } } return res; } } /*int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen("t.inp","r")) { freopen("test.inp","r",stdin); freopen("test.out","w",stdout); } cout <<findGap(1,10)<<endl; }*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...