Submission #69167

#TimeUsernameProblemLanguageResultExecution timeMemory
69167FedericoSGap (APIO16_gap)C++14
30 / 100
2077 ms2704 KiB
#include "gap.h" #include <vector> #include <iostream> #include <assert.h> #include <algorithm> using namespace std; typedef long long ll; ll INF=1e18; ll S=1e12; ll K=1000; ll x,y; vector<ll> V; void F(ll a, ll b){ MinMax(a,b,&x,&y); if(x==-1)return; if(a==b) V.push_back(a); else{ ll p=(b-a+K-1)/K; for(ll i=a;i<=b;i+=p) F(i,min(i+p-1,b)); } } long long findGap(int T, int N) { if(T==1){ y=INF; for(int i=0;i<(N+1)/2;i++){ MinMax(x,y,&x,&y); if(x==-1)break; V.push_back(x); V.push_back(y); x++; y--; if(x>y)break; } sort(V.begin(),V.end()); x=0; for(int i=0;i<V.size()-1;i++) x=max(x,V[i+1]-V[i]); return x; } MinMax(INF,INF,&x,&y); if(x!=-1) V.push_back(INF); for(ll i=0;i<INF;i+=S) F(i,i+S-1); sort(V.begin(),V.end()); x=0; for(int i=0;i<V.size()-1;i++) x=max(x,V[i+1]-V[i]); return x; } /* 1 6 1 2 5 7 8 12 */

Compilation message (stderr)

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:50:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<V.size()-1;i++)
               ~^~~~~~~~~~~
gap.cpp:67:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<V.size()-1;i++)
              ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...