# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
349397 | parsabahrami | Happiness (Balkan15_HAPPINESS) | C++11 | 2093 ms | 9964 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "happiness.h"
#pragma GCC optimize("O2")
#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 = 30;
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 < L; 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();
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |