Submission #954786

#TimeUsernameProblemLanguageResultExecution timeMemory
954786ItamarGap (APIO16_gap)C++14
100 / 100
56 ms10696 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 = 0, b = 1e18; vll v; int num = 0; for (int it = 0; it < (N + 1)/2 ; it++) { auto *at = new ll, *bt = new ll; MinMax(a, b , at, bt); a = *at, b = *bt; v.push_back(a); v.push_back(b); a++, b--; } sort(v.begin(), v.end()); ll ans = v[1]-v[0]; for (int i = 0; i+1 < v.size(); i++)if(v[i]>-1)ans = max(ans, v[i + 1] - v[i]); return ans; } else { auto* a = new ll, * b = new ll; MinMax(0, 1e18, a, b); vll v; ll d = ((* b) - (* a) + N - 2) / (N - 1); for (ll i = *a; i < *b; i += d + 1) { auto *c = new ll, * k = new ll; MinMax(i, i+d, c, k); v.push_back((ll)*c); v.push_back((ll) * k); } sort(v.begin(), v.end()); ll ans = d; for (int i = 0; i+1 < v.size(); 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:22:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |   for (int i = 0; i+1 < v.size(); i++)if(v[i]>-1)ans = max(ans, v[i + 1] - v[i]);
      |                   ~~~~^~~~~~~~~~
gap.cpp:12:7: warning: unused variable 'num' [-Wunused-variable]
   12 |   int num = 0;
      |       ^~~
gap.cpp:37:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |   for (int i = 0; i+1 < v.size(); i++) {
      |                   ~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...