#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) (ll)(log2(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 |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
4 ms |
860 KB |
Output is correct |
9 |
Correct |
4 ms |
860 KB |
Output is correct |
10 |
Correct |
4 ms |
860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
127 ms |
5972 KB |
Output is correct |
7 |
Correct |
119 ms |
6072 KB |
Output is correct |
8 |
Correct |
146 ms |
6228 KB |
Output is correct |
9 |
Correct |
189 ms |
6088 KB |
Output is correct |
10 |
Correct |
266 ms |
8664 KB |
Output is correct |
11 |
Correct |
148 ms |
10440 KB |
Output is correct |
12 |
Correct |
147 ms |
9948 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
4 ms |
860 KB |
Output is correct |
9 |
Correct |
4 ms |
860 KB |
Output is correct |
10 |
Correct |
4 ms |
860 KB |
Output is correct |
11 |
Correct |
127 ms |
5972 KB |
Output is correct |
12 |
Correct |
119 ms |
6072 KB |
Output is correct |
13 |
Correct |
146 ms |
6228 KB |
Output is correct |
14 |
Correct |
189 ms |
6088 KB |
Output is correct |
15 |
Correct |
266 ms |
8664 KB |
Output is correct |
16 |
Correct |
148 ms |
10440 KB |
Output is correct |
17 |
Correct |
147 ms |
9948 KB |
Output is correct |
18 |
Correct |
145 ms |
5928 KB |
Output is correct |
19 |
Correct |
150 ms |
6480 KB |
Output is correct |
20 |
Correct |
245 ms |
9136 KB |
Output is correct |
21 |
Correct |
146 ms |
10832 KB |
Output is correct |
22 |
Correct |
178 ms |
15812 KB |
Output is correct |
23 |
Correct |
153 ms |
16212 KB |
Output is correct |
24 |
Correct |
140 ms |
11272 KB |
Output is correct |