Submission #1086899

#TimeUsernameProblemLanguageResultExecution timeMemory
1086899serifefedartarHappiness (Balkan15_HAPPINESS)C++17
Compilation error
0 ms0 KiB
#include "happiness.h" #include <bits/stdc++.h> using namespace std; #define fast ios::sync_with_stdio(0);cin.tie(0) typedef long long ll; #define f first #define s second #define LOGN 21 const ll MOD = 1e9 + 7; const ll MAXN = 1e6 + 100; #define int long long struct Node { int l, r; int sum; Node *ln, *rn; Node(int _l, int _r) : l(_l), r(_r), sum(0), ln(NULL), rn(NULL) { } int query(int a, int b) { if (r < a || l > b) return 0; if (l <= a && b <= r) return sum; int res = 0; if (ln) res += ln->query(a, b); if (rn) res += rn->query(a, b); return res; } void update(int plc, int val) { sum += val; if (l != r) { int mid = (l + r) / 2; if (plc > mid) { if (!rn) rn = new Node(mid + 1, r); rn->update(plc, val); } else { if (!ln) ln = new Node(l, mid); ln->update(plc, val); } } } }; Node *root; bool solve() { int now = 1; while (now < root->sum) { int t = root->query(1, now); if (t < now) return false; now = t + 1; } return true; } bool init(int coinsCount, int maxCoinSize, int coins[]) { root = new Node(1, maxCoinSize); root->update(1, 1); for (int i = 0; i < coinsCount; i++) root->update(coins[i], coins[i]); return solve(); } bool is_happy(int event, int coinsCount, int coins[]) { for (int i = 0; i < coinsCount; i++) root->update(coins[i], event * coins[i]); return solve();

Compilation message (stderr)

happiness.cpp: In function 'bool is_happy(long long int, long long int, long long int*)':
happiness.cpp:73:19: error: expected '}' at end of input
   73 |     return solve();
      |                   ^
happiness.cpp:70:55: note: to match this '{'
   70 | bool is_happy(int event, int coinsCount, int coins[]) {
      |                                                       ^
grader.cpp: In function 'int main()':
grader.cpp:16:12: warning: unused variable 'max_code' [-Wunused-variable]
   16 |  long long max_code;
      |            ^~~~~~~~