Submission #73208

# Submission time Handle Problem Language Result Execution time Memory
73208 2018-08-28T04:49:58 Z 윤교준(#2271) Happiness (Balkan15_HAPPINESS) C++11
Compilation error
0 ms 0 KB
#include "happiness.h"
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

multiset<ll> CH[40];
ll S[40];

int getIdx(ll n) {
	for(int i = 1;; i++) {
		if(n < (1ll<<i))
			return i-1;
	}
}

bool getAns() {
	ll sum = 0, tot = 0;
	for(int i = 0; i < 40; i++) tot += S[i];
	for(int i = 0; i < 40; i++) {
		if(CH[i].empty()) continue;
		if(sum+1 < *CH[i].begin()) break;
		sum += S[i];
	}
	return sum == tot;
}

bool init(int cnt, ll mxcoin, ll A[]) {
	for(int i = 0, t; i < cnt; i++) {
		t = getIdx(A[i]);
		S[t] += A[i];
		CH[t].insert(A[i]);
	}
	return getAns();
}

bool is_happy(int evt, int cnt, ll A[]) {
	if(0 < evt) {
		for(int i = 0, t; i < cnt; i++) {
			t = getIdx(A[i]);
			S[t] += A[i];
			CH[t].insert(A[i]);
		}
	} else {
		for(int i = 0, t; i < cnt; i++) {
			t = getIdx(A[i]);
			S[t] -= A[i];
			CH[t].erase(CH[t].find(A[i]));
		}
	}
	return getAns();
}

Compilation message

g++-7: error: grader.cpp: No such file or directory