Submission #1092102

#TimeUsernameProblemLanguageResultExecution timeMemory
1092102vijaygomathinayagamHappiness (Balkan15_HAPPINESS)C++17
0 / 100
2050 ms344 KiB
#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)

grader.cpp: In function 'int main()':
grader.cpp:16:12: warning: unused variable 'max_code' [-Wunused-variable]
   16 |  long long max_code;
      |            ^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...