Submission #469951

#TimeUsernameProblemLanguageResultExecution timeMemory
469951jazzupGap (APIO16_gap)C++14
100 / 100
72 ms2232 KiB
#include "gap.h" #include<vector> #include<algorithm> using namespace std; vector<long long> v; long long st=0,ed=1e18; long long findGap(int T, int N){ if(T==1){ long long mn=st,mx=ed; for(int i=0;i<(N+1)/2;i++){ MinMax(mn,mx,&mn,&mx); v.push_back(mn); if(mx!=mn)v.push_back(mx); mn++; mx--; } sort(v.begin(),v.end()); long long ans=0; for(int i=0;i<v.size()-1;i++){ ans=max(ans,v[i+1]-v[i]); } return ans; } long long mn,mx; MinMax(st,ed,&mn,&mx); if (N == 2) return mx-mn; long long ga=mx-mn-1; long long s=mn+1,rec=mn,ans=0; for(int i=0;i<N;i++){ MinMax(s,s+1+ga/(N-1),&mn,&mx); if(mn!=-1){ ans=max(ans,mn-rec); rec=mx; } s=s+2+ga/(N-1); } return ans; }

Compilation message (stderr)

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:23:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |   for(int i=0;i<v.size()-1;i++){
      |               ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...