| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 427609 | CSQ31 | Happiness (Balkan15_HAPPINESS) | C++14 | 1559 ms | 372248 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "happiness.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct node{
ll lf,rg,sum;
node *l,*r;
node(ll _lf,ll _rg){
l = nullptr;
r = nullptr;
sum = 0;
lf = _lf;
rg = _rg;
}
void upd(ll val,ll c){
sum+=val*c;
if(lf==rg)return;
ll tm = (lf+rg)/2;
if(val<=tm){
if(l == nullptr)l = new node(lf,tm);
l->upd(val,c);
}else{
if(r == nullptr)r = new node(tm+1,rg);
r->upd(val,c);
}
}
long long query(long long a, long long b) {
if (rg < a || lf > b) return 0;
if (rg <= b && lf >= a) return sum;
long long ret = 0;
if (l) ret += l->query(a, b);
if (r) ret += r->query(a, b);
return ret;
}
};
ll m;
node *root;
bool check(){
ll cur = 1,mx = root->sum;
while(cur<mx){
ll t = root->query(1,cur);
if(cur>t)return false;
cur = t+1;
}
return true;
}
bool init(int coinsCount, long long maxCoinSize, long long coins[]) {
m = maxCoinSize;
root = new node(1,m);
for(int i=0;i<coinsCount;i++)root->upd(coins[i],1);
return check();
}
bool is_happy(int event, int coinsCount, long long coins[]) {
for(int i=0;i<coinsCount;i++)root->upd(coins[i],event);
return check();
}
컴파일 시 표준 에러 (stderr) 메시지
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
