Submission #667332

#TimeUsernameProblemLanguageResultExecution timeMemory
667332MahdiGap (APIO16_gap)C++17
56.31 / 100
59 ms2372 KiB
#include<bits/stdc++.h> #include "gap.h" using namespace std; #define all(v) v.begin(), v.end() typedef long long ll; long long findGap(int T, int N){ if(T==1){ vector<ll>v; ll a=-1, b=1e18+1, c, d; for(int i=0;i<N;i+=2){ MinMax(a+1, b-1, &c, &d); v.push_back(c); v.push_back(d); a=c; b=d; } sort(all(v)); ll ans=0; for(int i=1;i<v.size();++i) ans=max(ans, v[i]-v[i-1]); return ans; } ll a, b; MinMax(0, 1e18, &a, &b); ll c=(b-a)/(N-1); ll ans=c; while(a!=b){ ll d=-1, e; for(int i=1;d==-1;++i) MinMax(a+1, a+i*c, &d, &e); ans=max(ans, d-a); a=e; } return ans; }

Compilation message (stderr)

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