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