제출 #396152

#제출 시각아이디문제언어결과실행 시간메모리
396152giorgikobGap (APIO16_gap)C++14
0 / 100
60 ms1200 KiB
#include<bits/stdc++.h> #define ll long long #define ff first #define ss second #define pb push_back using namespace std; //#include "game.h" #include "gap.h" ll answer = 0; void solve(ll l, ll r){ //cout << l << " " << r << endl; //answer = min(answer,r-l); ll mid = (l+r)/2; ll a,b; if(l+1 <= mid)MinMax(l+1,mid,&a,&b); if(a != -1){ if(a == b){ answer = max(a-l,answer); } else { answer = max(a-l,answer); solve(a,b); } } else { answer = max(answer,r-l); } ll k = b; if(mid+1 <= r-1)MinMax(mid+1,r-1,&a,&b); if(a != -1){ answer = max(answer,a-k); if(a == b){ answer = max(r-a,answer); } else { answer = max(r-a,answer); solve(a,b); } } else { answer = max(answer,r-l); } } long long findGap(int T, int N) { ll pirveli, bolo; MinMax(1,1e18,&pirveli,&bolo); //cout << pirveli << " " << bolo << endl; //solve(pirveli,bolo); ll l = pirveli, r = bolo; //if(T == 1) while(true){ ll new_l,new_r; MinMax(l+1,r-1,&new_l,&new_r); if(new_l == -1){ answer = max(answer,r-l); break; } else { answer = max(answer, max(new_l-l,r-new_r)); l = new_l; r = new_r; } } return answer; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...