Submission #1092111

# Submission time Handle Problem Language Result Execution time Memory
1092111 2024-09-23T08:19:58 Z vijaygomathinayagam Happiness (Balkan15_HAPPINESS) C++17
0 / 100
0 ms 348 KB
#include "happiness.h"

long long max_two_power_above_sum = 1;
long long sum = 0;

void add(long long x) {
	sum += x;
}

void remove(long long x) {
	sum -= x;
}

bool check() {
	max_two_power_above_sum = 1;
	while (max_two_power_above_sum < sum)
		max_two_power_above_sum *= 2;
	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

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 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -