Submission #349394

#TimeUsernameProblemLanguageResultExecution timeMemory
349394parsabahramiHappiness (Balkan15_HAPPINESS)C++17
40 / 100
2089 ms13804 KiB
#include "happiness.h" #include <bits/stdc++.h> using namespace std; typedef long long int ll; #define SZ(x) (int) x.size() #define F first #define S second const int L = 40; ll S[L]; multiset<ll> M[L]; void add(ll x, int b) { int g = 0; while ((1 << (g + 1)) <= x) g++; S[g] += b * x; if (~b) M[g].insert(x); else M[g].erase(M[g].find(x)); } int check() { ll sum = 0; for (int i = 0; i < 40; i++) { if (!SZ(M[i])) continue; ll x = *M[i].begin(); if (sum + 1 < x) return 0; if (SZ(M[i]) > 1 && *next(M[i].begin()) > sum + 1 + x) return 0; sum += S[i]; } return 1; } bool init(int coinsCount, long long maxCoinSize, long long coins[]) { for (int i = 0; i < coinsCount; i++) add(coins[i], 1); return check(); } bool is_happy(int event, int coinsCount, long long coins[]) { for (int i = 0; i < coinsCount; i++) { add(coins[i], event); } 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...