Submission #474653

# Submission time Handle Problem Language Result Execution time Memory
474653 2021-09-19T09:41:01 Z cpp219 Happiness (Balkan15_HAPPINESS) C++14
0 / 100
1 ms 204 KB
#include<bits/stdc++.h>
#include <happiness.h>
#define ll long long
#define ld long double
#define fs first
#define sc second
#define debug(y) cout<<y,exit(0)
using namespace std;
typedef pair<ll,ll> LL;
const ll N = 2e5 + 9;
const ll inf = 1e9 + 7;

multiset<ll> s[45];
ll bucket[45];

void Add(ll cond,ll x){
    ll now = 1,cur = 0;
    while(now < x) now *= 2,cur++;
    if (cond > 0) s[cur].insert(x);
    else s[cur].erase(s[cur].find(x));
    bucket[cur] += x;
}

bool chk(){
    ll sum = 0;
    for (ll i = 0;i <= 40;i++) if (s[i].size()){
        ll now = *s[i].begin();
        if (sum + 1 < now) return 0;
        if (s[i].size() > 1 && sum + now + 1 < *next(s[i].begin())) return 0;
        sum += bucket[i];
    }
    return 1;
}

bool init(int coinsCount,ll maxCoinSize,ll coins[]){
    for (ll i = 0;i < coinsCount;i++) Add(1,coins[i]);
    return chk();
}

bool is_happy(int event, int coinsCount,ll coins[]){
    for (ll i = 0;i < coinsCount;i++) Add(event,coins[i]);
    return chk();
}
/*
int main(){
    ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0);
    #define task "tst"
    if (fopen(task".inp","r")){
        freopen(task".inp","r",stdin);
        //freopen(task".out","w",stdout);
    }

}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
	* DON'T GET STUCK ON ONE APPROACH
*/

Compilation message

happiness.cpp:55:1: warning: "/*" within comment [-Wcomment]
   55 | /* stuff you should look for
      |  
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 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -