# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1019674 | NoLove | Happiness (Balkan15_HAPPINESS) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/**
* author : Lăng Trọng Đạt
* created: 11-07-2024
**/
#include <bits/stdc++.h>
#include "happiness.h"
using namespace std;
#ifndef LANG_DAT
#define db(...) ;
#endif // LANG_DAT
#define int long long
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define all(v) (v).begin(), (v).end()
using pii = pair<int, int>;
using vi = vector<int>;
#define FOR(i, a, b) for (int (i) = a; (i) <= (b); i++)
void mx(int& a, int b) { if (b > a) a = b; }
void mi(int& a, int b) { if (b < a) a = b; }
#define si(x) (int)(x.size())
const int INF = 1e18;
const int MOD = 1e9 + 7;
multiset<int> vals;
bool init(int coinsCount, long long maxCoinSize, long long coins[]) {
FOR(i, 0, coinsCount - 1)
vals.insert(coins[i]);
return true;
}
bool is_happy(int event, int coinsCount, long long coins[]) {
FOR(i, 0, coinsCount - 1)
if (event == 1)
vals.insert(coins[i]);
else vals.erase(coins[i]);
int s = 1;
for (int i : vals) {
if (s < i) return false;
s += i;
}
return true;
}