| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1319728 | thuhienne | Happiness (Balkan15_HAPPINESS) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
#include "happiness.h"
using namespace std;
using ll = long long;
#define thuhien ""
#define re exit(0);
multiset <int> coins;
bool check(multiset <int> & a) {
ll s = 1;
for (int x : a) {
if (x > s) return 0;
s += x;
}
return 1;
}
bool init(int cnt,ll maxsize,vector <ll> tmp) {
for (int x : tmp) coins.insert(x);
return check(coins);
}
bool is_happy(int type,int cnt,vector <ll> tmp) {
for (int x : tmp) {
if (type == -1) coins.erase(coins.find(x));
else coins.insert(x);
}
return check(coins);
}
