Submission #343161

#TimeUsernameProblemLanguageResultExecution timeMemory
343161jjwdi0Gap (APIO16_gap)C++11
30 / 100
75 ms2508 KiB
#include "gap.h" #include <bits/stdc++.h> using namespace std; using ll = long long; ll solve1(int N) { int x = (N + 1) / 2; vector<ll> v; ll s = 0, e = 1e18, mn, mx; for(int i=0; i<x; i++) { MinMax(s, e, &mn, &mx); v.push_back(mn); if(mn != mx) v.push_back(mx); s = mn + 1, e = mx - 1; } sort(v.begin(), v.end()); ll ans = 0; for(int i=1; i<N; i++) { ans = max(ans, v[i] - v[i-1]); } return ans; } ll solve2(int N) { ll s = 0, e = 1e18, mn, mx; MinMax(s, e, &mn, &mx); ll T = (e - s + N - 2) / (N - 1); vector<ll> v; ll l = s, r = s + T; for(int i=1; i<N; i++) { MinMax(l, r, &mn, &mx); if(mn != -1) v.push_back(mn), v.push_back(mx); l += T + 1, r += T + 1; } ll ans = 0; for(int i=1; i<v.size(); i++) { ans = max(ans, v[i] - v[i-1]); } return ans; } ll findGap(int T, int N) { if(T == 1) return solve1(N); return solve2(N); }

Compilation message (stderr)

gap.cpp: In function 'll solve2(int)':
gap.cpp:36:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for(int i=1; i<v.size(); i++) {
      |                  ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...