Submission #379344

#TimeUsernameProblemLanguageResultExecution timeMemory
379344pavementRice Hub (IOI11_ricehub)C++17
100 / 100
17 ms2540 KiB
#include "ricehub.h" #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #ifdef TEST #define getchar_unlocked _getchar_nolock #define putchar_unlocked _putchar_nolock #endif #define ins insert #define mp make_pair #define mt make_tuple #define pb push_back #define pf push_front #define pp pop #define ppb pop_back #define ppf pop_front #define eb emplace_back #define g0(a) get<0>(a) #define g1(a) get<1>(a) #define g2(a) get<2>(a) #define g3(a) get<3>(a) mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); typedef double db; typedef long long ll; typedef pair<int, int> ii; typedef tuple<int, int, int> iii; typedef tree<pair<int, int>, null_type, less<pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set; typedef tree<pair<int, int>, null_type, less<pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set; ll P[100005]; int besthub(int R, int L, int X[], ll B) { int lo = 1, hi = R, mid, rh, ans; P[0] = (ll)X[0]; for (int i = 1; i < R; i++) P[i] = P[i - 1] + (ll)X[i]; while (lo <= hi) { bool yes = 0; mid = (lo + hi) >> 1; for (int i = 0; i <= R - mid; i++) { rh = i + mid / 2; ll res = (ll)(rh - i + 1) * (ll)X[rh] - (ll)P[rh] + (ll)(i ? P[i - 1] : 0) + (ll)P[i + mid - 1] - (ll)(rh ? P[rh - 1] : 0) - (ll)(i + mid - rh) * (ll)X[rh]; if (res <= B) { yes = 1; break; } } if (yes) ans = mid, lo = mid + 1; else hi = mid - 1; } return ans; }

Compilation message (stderr)

ricehub.cpp: In function 'int besthub(int, int, int*, ll)':
ricehub.cpp:53:9: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   53 |  return ans;
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...