Submission #1208629

#TimeUsernameProblemLanguageResultExecution timeMemory
1208629phungmanager0Happiness (Balkan15_HAPPINESS)C++20
Compilation error
0 ms0 KiB
#include "happiness.h" #include <bits/stdc++.h> multiset<long long> s[40]; int sum[40]; void update(int x, bool del) { int k = 31 - __builtin_clz(x); if(del) { s[k].erase(x); sum[k] -= x; } else { s[k].insert(x); sum[k] += x; } } bool get() { int sum = 0; for(int i = 0; i < 40; i++) { if(s[i].size()) { auto it = s[i].begin(); if(*it <= sum + 1) { if(s[i].size() > 1) { if(sum + *it + 1 < *(++it)) return false; } } else return false; } } return true; } bool is_happy(int event, int coinsCount, long long coins[]) { for(int i = 0; i < coinsCount; i++) { if(event == -1) update(coins[i], true); else update(coins[i], false); } return get(); } bool init(int coinsCount, long long maxCoinSize, long long coins[]) { for(int i = 0; i < coinsCount; i++) update(coins[i], false); return get(); }

Compilation message (stderr)

happiness.cpp:4:1: error: 'multiset' does not name a type
    4 | multiset<long long> s[40];
      | ^~~~~~~~
happiness.cpp: In function 'void update(int, bool)':
happiness.cpp:9:9: error: 's' was not declared in this scope
    9 |         s[k].erase(x);
      |         ^
happiness.cpp:12:9: error: 's' was not declared in this scope
   12 |         s[k].insert(x);
      |         ^
happiness.cpp: In function 'bool get()':
happiness.cpp:19:12: error: 's' was not declared in this scope
   19 |         if(s[i].size()) {
      |            ^