Submission #23500

#TimeUsernameProblemLanguageResultExecution timeMemory
23500jun6873Gap (APIO16_gap)C++14
100 / 100
99 ms8308 KiB
#include "gap.h" #include <bits/stdc++.h> using namespace std; typedef long long lint; vector<lint> v; lint findGap(int t, int n) { lint mn=0, mx=1e18; if (t == 1) { for (int i=0; i<(n+1)/2; i++) { MinMax(mn, mx, &mn, &mx); v.push_back(mn); v.push_back(mx); mn++; mx--; } } else { MinMax(mn, mx, &mn, &mx); v.push_back(mn); v.push_back(mx); lint k = (mx-mn+n-2)/(n-1)+1, now = mn, nxt = mn+k; while (now <= mx) { lint a, b; MinMax(now, nxt-1, &a, &b); now += k; nxt += k; if (a>=0) v.push_back(a); if (b>=0) v.push_back(b); } } sort(v.begin(), v.end()); lint res = 0; for (int i=0; i<v.size()-1; i++) res = max(res, v[i+1] - v[i]); return res; }

Compilation message (stderr)

gap.cpp: In function 'lint findGap(int, int)':
gap.cpp:36:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=0; i<v.size()-1; i++) res = max(res, v[i+1] - v[i]);
                 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...