| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 917897 | vjudge1 | Happiness (Balkan15_HAPPINESS) | C++17 | 8 ms | 2140 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.
#include "happiness.h"
#define V coins[i]
#include<bits/stdc++.h>
using namespace std;
#define ll long long
multiset<ll> st[40];
#define L(x) (63-__builtin_clz(x))
ll sum[40];
bool check() {
    ll s = 0;
    for(int i = 0; i < 40; s+=sum[i++])
        if(st[i].size()&&*st[i].begin()-s>1)    
            return 0;
    return 1;
}
bool init(int coinsCount, ll maxCoinSize, ll coins[]) {
    for(int i=0;i<coinsCount;i++)
        st[L(V)].insert(V),sum[L(V)]+=V;
    return check();
}
bool is_happy(int event, int coinsCount, ll coins[]) {
	for(int i=0;i<coinsCount;i++)
        if(event>0)
            st[L(V)].insert(V), sum[L(V)]+=V;
        else
            st[L(V)].erase(st[L(V)].find(V)),sum[L(V)]-=V;
    return check();
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
