# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
368159 | cheissmart | Happiness (Balkan15_HAPPINESS) | C++14 | 2074 ms | 6636 KiB |
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 "happiness.h"
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define V vector
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << "LINE(" << __LINE__ << ") -> " << #x << " is " << (x) << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;
const int INF = 1e9 + 7;
const ll oo = 1e18;
multiset<int> s;
void add_coins(ll val) {
s.insert(val);
}
void del_coins(ll val) {
s.erase(s.find(val));
}
bool happy() {
ll sum = 0;
for(ll i:s) {
if(i > sum + 1) return false;
sum += i;
}
return true;
}
bool init(int coinsCount, long long maxCoinSize, long long coins[]) {
s.clear();
for(int i = 0; i < coinsCount; i++) {
add_coins(coins[i]);
}
return happy();
}
bool is_happy(int event, int coinsCount, long long coins[]) {
if(event == 1) { // add
for(int i = 0; i < coinsCount; i++)
add_coins(coins[i]);
} else { // del
for(int i = 0; i < coinsCount; i++)
del_coins(coins[i]);
}
return happy();
}
Compilation message (stderr)
# | 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... |