#include <bits/stdc++.h>
using namespace std;
#ifndef LOCAL
#include <happiness.h>
#endif
#ifdef DEBUG
auto&operator<<(auto &o, pair<auto, auto> p) {o << "(" << p.first << ", " << p.second << ")"; return o;}
auto operator<<(auto &o, auto x)->decltype(x.end(), o) {o<<"{"; for(auto e : x) o<<e<<", "; return o<<"}";}
#define debug(X) cerr << "["#X"]: " << X << '\n';
#else
#define debug(X) ;
#endif
#define ll long long
#define all(v) (v).begin(), (v).end()
#define FOR(i,l,r) for(int i=(l);i<=(r);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define ssize(x) int(x.size())
#define fi first
#define se second
struct Node {
ll val, lazy;
ll start, end;
Node *left, *right;
Node() {
val = lazy = 0;
start = 0; end = (ll)((ll)1<<40)-1;
left = right = nullptr;
}
};
Node root;
void push_to_sons(Node &v) {
ll x = v.lazy;
if (x == 0) return;
(v.left)->val += x;
(v.right)->val += x;
(v.left)->lazy += x;
(v.right)->lazy += x;
v.lazy = 0;
}
void update(ll a, ll x, Node v) {
ll l = v.start, r = v.end;
if (r < a || a < l) return;
push_to_sons(v);
update(a, x, *v.left); update(a, x, *v.right);
v.val = (v.left)->val+(v.right)->val;
}
ll query(ll a, ll b, Node v) {
ll l = v.start, r = v.end;
if (r < a || b < l) return 0;
if (a <= l && r <= b) return v.val;
push_to_sons(v);
return query(a, b, *v.left) + query(a, b, *v.right);
}
bool check() {
ll curr = 1, sum = root.val;
while (curr < sum) {
ll t = query(0, curr, root);
if (t < curr) return false;
curr = t+1;
}
return true;
}
bool init(int coinsCount, long long maxCoinSize, long long coins[]) {
REP(i, coinsCount) {
update(coins[i], coins[i], root);
}
return check();
}
bool is_happy(int event, int coinsCount, long long coins[]) {
REP(i, coinsCount) {
update(coins[i], event*coins[i], root);
}
return check();
}
#ifdef LOCAL
int main () {
}
#endif
Compilation message
grader.cpp: In function 'int main()':
grader.cpp:16:12: warning: unused variable 'max_code' [-Wunused-variable]
16 | long long max_code;
| ^~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |