Submission #1113760

#TimeUsernameProblemLanguageResultExecution timeMemory
1113760simona1230Gap (APIO16_gap)C++17
30 / 100
41 ms3960 KiB
#include <bits/stdc++.h> #include "gap.h" using namespace std; long long ans,mn,mx; vector<long long> v; void solve(long long l,long long r) { if(l>r)return; long long m=(l+r)/2,mn1,mx1; MinMax(l,r,&mn1,&mx1); if(mn1==-1)return; v.push_back(mn1); if(mx1!=mn1)v.push_back(mx1); else return; solve(mn1+1,m); solve(m+1,mx1-1); } long long findGap(int t,int n) { if(1) { long long l=0,r=1e18; while(l<=r&&v.size()<n) { long long minn,maxx; MinMax(l,r,&minn,&maxx); if(minn==-1)break; v.push_back(minn); if(minn!=maxx)v.push_back(maxx); l=minn+1,r=maxx-1; } } else solve(0,1e18); sort(v.begin(),v.end()); for(int i=1; i<v.size(); i++) ans=max(ans,v[i]-v[i-1]); return ans; }

Compilation message (stderr)

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