#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
grader.cpp: In function 'int main()':
grader.cpp:16:12: warning: unused variable 'max_code' [-Wunused-variable]
16 | long long max_code;
| ^~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Runtime error |
8 ms |
2140 KB |
Execution killed with signal 11 |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
7 |
Halted |
0 ms |
0 KB |
- |