#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;
for(; i <= 40; i ++)
{
st[i].insert(x);
fe[i] += x;
}
}
void del(ll x)
{
int i = 0;
while(1ll<<(i+1) < x)++i;
for(; i <= 40; 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 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |