Submission #1319744

#TimeUsernameProblemLanguageResultExecution timeMemory
1319744thuhienneHappiness (Balkan15_HAPPINESS)C++20
30 / 100
2094 ms5704 KiB
#include <bits/stdc++.h>
#include "happiness.h"
using namespace std;

using ll = long long;

#define thuhien ""
#define re exit(0);

multiset <ll> coins;

bool check(multiset <ll> & a) {
	if (a.empty()) return 1;
	
	ll s = 0;
	for (ll x : a) {
		if (x - 1 > s) return 0;
		s += x;
	}
	return 1;
}
bool init(int cnt,ll maxsize,ll tmp[]) {
	for (int i = 0;i < cnt;i++) coins.insert(tmp[i]);
	return check(coins);
}
bool is_happy(int type,int cnt,ll tmp[]) {
	for (int i = 0;i < cnt;i++) {
		if (type == -1) coins.erase(coins.find(tmp[i]));
		else coins.insert(tmp[i]);
	}
	return check(coins);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...