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 <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 (stderr)
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 |
---|
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... |