#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pll pair<ll, ll>
#define pii pair<ll, pll>
#define pd pair<ld, ll>
#define pb push_back
#define fi first
#define se second
//#include "happiness.h"
using namespace std;
const int N = 45;
const int M = 1300;
const ll mod = 1e15+7;
ll n, m, k, t, a[N], b[N], c[N], tong, ans, fe[N];
vector<ll> kq, adj[N];
vector<pll> P;
multiset<ll> st[N];
void add(ll x)
{
int i = 0;
while(1ll<<(i+1) <= x)++i;
st[i].insert(x);
fe[i] += x;
}
void del(ll x)
{
int i = 0;
while(1ll<<(i+1) <= x)++i;
st[i].erase(st[i].find(x));
fe[i] -= x;
}
bool ok()
{
ll total = 0;
for(int i = 0; i <= 40; i ++)
{
if(!st[i].empty())
{
if(total+1 < (*st[i].begin()))return false;
if(st[i].size() > 1 &&total+1+(*st[i].begin()) < (*next(st[i].begin())))return false;
}
total += fe[i];
}
return true;
}
bool init(int coinsCount, long long maxCoinSize, long long coins[]) {
for (int i = 0; i < coinsCount; ++i)add(coins[i]);
return ok();
}
bool is_happy(int event, int coinsCount, long long coins[]) {
for (int i = 0; i < coinsCount; ++i) {
if (event == -1) del(coins[i]);
else add(coins[i]);
}
return ok();
}
Compilation message
grader.cpp: In function 'int main()':
grader.cpp:16:12: warning: unused variable 'max_code' [-Wunused-variable]
16 | long long max_code;
| ^~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
6 ms |
1056 KB |
Output is correct |
9 |
Correct |
6 ms |
972 KB |
Output is correct |
10 |
Correct |
5 ms |
972 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
197 ms |
8964 KB |
Output is correct |
7 |
Correct |
238 ms |
8992 KB |
Output is correct |
8 |
Correct |
181 ms |
8976 KB |
Output is correct |
9 |
Correct |
275 ms |
10324 KB |
Output is correct |
10 |
Correct |
372 ms |
12904 KB |
Output is correct |
11 |
Correct |
183 ms |
13548 KB |
Output is correct |
12 |
Correct |
195 ms |
13764 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
6 ms |
1056 KB |
Output is correct |
9 |
Correct |
6 ms |
972 KB |
Output is correct |
10 |
Correct |
5 ms |
972 KB |
Output is correct |
11 |
Correct |
197 ms |
8964 KB |
Output is correct |
12 |
Correct |
238 ms |
8992 KB |
Output is correct |
13 |
Correct |
181 ms |
8976 KB |
Output is correct |
14 |
Correct |
275 ms |
10324 KB |
Output is correct |
15 |
Correct |
372 ms |
12904 KB |
Output is correct |
16 |
Correct |
183 ms |
13548 KB |
Output is correct |
17 |
Correct |
195 ms |
13764 KB |
Output is correct |
18 |
Correct |
223 ms |
11292 KB |
Output is correct |
19 |
Correct |
234 ms |
11424 KB |
Output is correct |
20 |
Correct |
393 ms |
14404 KB |
Output is correct |
21 |
Correct |
215 ms |
10768 KB |
Output is correct |
22 |
Correct |
210 ms |
15664 KB |
Output is correct |
23 |
Correct |
284 ms |
16068 KB |
Output is correct |
24 |
Correct |
214 ms |
11268 KB |
Output is correct |