Submission #107818

#TimeUsernameProblemLanguageResultExecution timeMemory
107818Noam527Gap (APIO16_gap)C++17
89.04 / 100
98 ms3304 KiB
#include <bits/stdc++.h> #define CHECK cout << "ok" << endl #define finish(x) return cout << x << endl, 0 typedef long long ll; typedef long double ldb; const int md = 1e9 + 7; const ll inf = 1e18; const int OO = 1; const int OOO = 1; using namespace std; void MinMax(ll s, ll t, ll *mn, ll *mx); ll findGap(int t, int n) { ll lo, hi, a, b; MinMax(0, inf, &lo, &hi); if (t == 2) { vector<ll> pos; ll d = (hi - lo) / (n - 1); pos.push_back(lo); for (ll i = lo + 1; i < hi; i += d) { MinMax(i, min(hi - 1, i + d - 1), &a, &b); if (a != -1) { pos.push_back(a); pos.push_back(b); } } pos.push_back(hi); ll rtn = pos[1] - pos[0]; for (int i = 2; i < pos.size(); i++) rtn = max(rtn, pos[i] - pos[i - 1]); return rtn; } vector<ll> pos = { lo, hi }; int left = n - 2; while (left > 0) { MinMax(lo + 1, hi - 1, &lo, &hi); pos.push_back(lo); pos.push_back(hi); left -= 2; } sort(pos.begin(), pos.end()); ll rtn = pos[1] - pos[0]; for (int i = 2; i < pos.size(); i++) rtn = max(rtn, pos[i] - pos[i - 1]); return rtn; } /* int main() { ll ans = findGap(0, 4); cout << "my ans " << ans << '\n'; } */

Compilation message (stderr)

gap.cpp: In function 'll findGap(int, int)':
gap.cpp:30:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 2; i < pos.size(); i++)
                   ~~^~~~~~~~~~~~
gap.cpp:44:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 2; i < pos.size(); i++)
                  ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...