Submission #1283639

#TimeUsernameProblemLanguageResultExecution timeMemory
1283639ryazimnHappiness (Balkan15_HAPPINESS)C++20
Compilation error
0 ms0 KiB
#include "happiness.h" #include <bits/stdc++.h> typedef long long ll; const ll A = 1e12 + 1, N = 7e5 + 1; int n, tot = 1; ll ma; ll seg[N * 41]; int ls[N * 41], rs[N * 41]; void add(int x, ll st, ll ed, ll pos, ll val) { if (st == ed) { seg[x] += val; return; } ll mid = (st + ed) / 2; if (pos <= mid) { if (ls[x] == 0) { ls[x] = ++tot; } add(ls[x], st, mid, pos, val); } else { if (rs[x] == 0) { rs[x] = ++tot; } add(rs[x], mid + 1, ed, pos, val); } seg[x] = seg[ls[x]] + seg[rs[x]]; } ll getSum(int x, ll st, ll ed, ll l, ll r) { if (st > r || ed < l || x == 0) { return 0; } if (l <= st && ed <= r) { return seg[x]; } ll mid = (st + ed) / 2; return getSum(ls[x], st, mid, l, r) + getSum(rs[x], mid + 1, ed, l, r); } bool check() { ll cur = 1; while (cur < min(seg[1], ma)) { ll t = getSum(1, 1, ma, 1, cur); if (t + 1 <= cur) { return false; } cur = t + 1; } return 1; } bool init(int coinsCount, long long maxCoinSize, long long c[]) { ma = maxCoinSize; n = coinsCount; for (int i = 0; i < n; i++) { add(1, 1, ma, c[i], c[i]); } return check(); } bool is_happy(int event, int coinsCount, long long c[]) { for (int i = 0; i < coinsCount; i++) { add(1, 1, ma, c[i], c[i] * event); } return check(); }

Compilation message (stderr)

happiness.cpp: In function 'bool check()':
happiness.cpp:40:18: error: 'min' was not declared in this scope
   40 |     while (cur < min(seg[1], ma)) {
      |                  ^~~
happiness.cpp:40:18: note: suggested alternatives:
In file included from /usr/include/c++/13/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from happiness.cpp:2:
/usr/include/c++/13/bits/stl_algo.h:5785:5: note:   'std::min'
 5785 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
In file included from /usr/include/c++/13/bits/ranges_algo.h:39,
                 from /usr/include/c++/13/algorithm:63:
/usr/include/c++/13/bits/ranges_util.h:738:29: note:   'std::ranges::min'
  738 |   inline constexpr __min_fn min{};
      |                             ^~~