Submission #400579

#TimeUsernameProblemLanguageResultExecution timeMemory
400579HazemGap (APIO16_gap)C++14
0 / 100
74 ms2852 KiB
#include <bits/stdc++.h> #include "gap.h" using namespace std; #define LL long long #define F first #define S second #define pii pair<int,int> #define piii pair<pair<int,int>,int> const int M = 2e3+10; const LL INF = 1e9; const LL LINF = 1e18; const LL MOD = 1e9+7; const double PI = 3.141592653589793; long long findGap(int T, int N) { LL *l1 = new long long,*r1 = new long long; LL *l = new long long ,*r = new long long; LL cur = 0; *l = *l1 = 0; *r = *r1 = LINF+1; vector<LL>vec; for(int i=1;;i++){ *l1 = *l;*r1 = *r; if(*l+1+cur<=*r-1-cur) MinMax(*l+1+cur,*r-1-cur,l,r); else break; if(*l==-1){ cur = max(cur,*r-*l); break; } LL *p1 = new long long,*p2 = new long long; *p1 = *p2 = -1; if(*l!=*r){ MinMax(*l+1,*r-1,p1,p2); if(*p1==-1) cur = max(cur,*r-*l); } if(i==1)continue; if(*l1+1<=*l-1) MinMax(*l1+1,*l-1,p1,p2); if(*p1==-1)cur = max(cur,*l-*l1); *p1 = -1; if(*r+1<=*r1-1) MinMax(*r+1,*r1-1,p1,p2); if(*p1==-1)cur = max(cur,*r1-*r); } return cur; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...