# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1092102 | vijaygomathinayagam | Happiness (Balkan15_HAPPINESS) | C++17 | 2050 ms | 344 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"
long long max_two_power_above_sum = 1;
long long sum = 0;
void add(long long x) {
sum += x;
while (max_two_power_above_sum < sum)
max_two_power_above_sum *= 2;
}
void remove(long long x) {
sum -= x;
while ((max_two_power_above_sum / 2) > sum)
max_two_power_above_sum /= 2;
}
bool check() {
return max_two_power_above_sum - 1 == sum;
}
bool init(int coinsCount, long long maxCoinSize, long long coins[]) {
for (int i = 0; i < coinsCount; i++)
add(coins[i]);
return check();
}
bool is_happy(int event, int coinsCount, long long coins[]) {
for (int i = 0; i < coinsCount; i++)
remove(coins[i]);
return check();
}
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... |