Submission #532237

#TimeUsernameProblemLanguageResultExecution timeMemory
532237CaroLindaHappiness (Balkan15_HAPPINESS)C++14
100 / 100
371 ms27716 KiB
#include "happiness.h" #include <bits/stdc++.h> const int MAX = 45 ; using namespace std ; map<long long , int > del ; long long s[MAX] ; priority_queue< long long, vector<long long> , greater<long long> > fila[MAX] ; bool is_happy(int event, int coinsCount, long long coins[]) { for(int i = 0 ; i < coinsCount ; i++ ){ int bit = 64-__builtin_clzll(coins[i]) ; if(event == 1){ s[bit] += coins[i] ; fila[bit].push(coins[i]) ; } else{ s[bit] -= coins[i] ; del[coins[i]]++ ; } } long long ss = 0 ; for(int i = 0 ; i <= 40 ; i++ ){ while( !fila[i].empty() && del[ fila[i].top() ] ){ del[ fila[i].top() ]-- ; fila[i].pop() ; } if( !fila[i].empty() && fila[i].top() > ss+1 ) return false ; ss += s[i] ; } return true ; } bool init(int coinsCount, long long maxCoinSize, long long coins[]) { return is_happy( 1 , coinsCount, coins ) ; }

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...