Submission #954742

#TimeUsernameProblemLanguageResultExecution timeMemory
954742ItamarGap (APIO16_gap)C++14
0 / 100
20 ms5924 KiB
#include "gap.h" using namespace std; #define ll long long #include <vector> #define vll vector<ll> #include <algorithm> long long findGap(int T, int N) { if (T == 1) { ll a = -1, b = 1e18 + 1; vll v; for (int it = 0; it < (N + 1) / 2; it++) { ll* at = NULL, * bt = NULL; *at = 0, * bt = 0; MinMax(a + 1, b - 1, at, bt); a = *at, b = *bt; v.push_back(a); v.push_back(b); } sort(v.begin(), v.end()); ll ans = 0; for (int i = 0; i < v.size() - 1; i++)ans = max(ans, v[i + 1] - v[i]); return ans; } else { ll* a = NULL, * b = NULL; *a = 0, * b = 0; MinMax(0, 1e18, a, b); vll v; ll d = (b - a + N - 2) / (N - 1); for (int i = *a; i < *b; i += d + 1) { ll* c = NULL, * k = NULL; *c = 0, * k = 0; MinMax(i, i + d, c, k); v.push_back(*c); v.push_back(*k); } sort(v.begin(), v.end()); ll ans = d; for (int i = 0; i < v.size() - 1; i++) { if (v[i] > -1) { ans = max(ans, v[i + 1] - v[i]); } } return ans; } }

Compilation message (stderr)

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