이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pll pair<ll, ll>
#define pii pair<ll, pll>
#define pd pair<ld, ll>
#define pb push_back
#define fi first
#define se second
#include "happiness.h"
using namespace std;
const int N = 45;
const int M = 1300;
const ll mod = 1e15+7;
ll n, m, k, t, a[N], b[N], c[N], tong, ans, fe[N];
vector<ll> kq, adj[N];
vector<pll> P;
multiset<ll> st[N];
void add(ll x)
{
int i = 0;
while(1ll<<(i+1) <= x)++i;
st[i].insert(x);
fe[i] += x;
}
void del(ll x)
{
int i = 0;
while(1ll<<(i+1) <= x)++i;
st[i].erase(st[i].find(x));
fe[i] -= x;
}
bool ok()
{
ll total = 0;
for(int i = 0; i <= 40; i ++)
{
if(!st[i].empty())
{
if(total+1 < (*st[i].begin()))return false;
if(st[i].size() > 1 &&total+1+(*st[i].begin()) < (*next(st[i].begin())))return false;
}
total += fe[i];
}
return true;
}
bool init(int coinsCount, long long maxCoinSize, long long coins[]) {
for (int i = 0; i < coinsCount; ++i)add(coins[i]);
return ok();
}
bool is_happy(int event, int coinsCount, long long coins[]) {
for (int i = 0; i < coinsCount; ++i) {
if (event == -1) del(coins[i]);
else add(coins[i]);
}
return ok();
}
컴파일 시 표준 에러 (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... |