Submission #475602

#TimeUsernameProblemLanguageResultExecution timeMemory
475602Killer2501Happiness (Balkan15_HAPPINESS)C++14
100 / 100
393 ms16068 KiB
#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 (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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...