Submission #394436

#TimeUsernameProblemLanguageResultExecution timeMemory
394436danielcm585Gap (APIO16_gap)C++14
100 / 100
72 ms3252 KiB
#include "gap.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; const ll MX = 1e18; ll x, y; vector<ll> p; void query(ll l, ll r) { MinMax(l,r,&x,&y); if (x != -1) p.push_back(x); if (y != -1) p.push_back(y); } ll findGap(int T, int N) { ll l = 0, r = MX; if (T == 1) { for (int i = 1; i <= (N+1)/2 && l <= r; i++) { query(l,r); l = x+1, r = y-1; } } else { query(l,r); l = x+1, r = y-1; for (int i = N-1; i > 0; i--) { ll q = l+(r-l)/i; query(l,q); l = q+1; } } sort(p.begin(),p.end()); p.resize(unique(p.begin(),p.end())-p.begin()); ll ans = 0; for (int i = 1; i < p.size(); i++) { ans = max(ans,p[i]-p[i-1]); } return ans; }

Compilation message (stderr)

gap.cpp: In function 'll findGap(int, int)':
gap.cpp:38:20: 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 < p.size(); i++) {
      |                  ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...