#include "happiness.h"
#include <bits/stdc++.h>
using namespace std;
const long long MAX_M = 3e12;
const long long inf = 1e12;
int mistakes;
unordered_map<long long, int> frecv;
struct SegTree {
struct node {
node *left, *right;
long long minn, lazy;
};
node *createNode() {
node *x = new node;
x->left = x->right = NULL;
x->minn = x->lazy = 0;
return x;
}
node *root;
void propag( node *v, long long l, long long r ) {
v->minn += v->lazy;
if ( l != r ) {
v->left->lazy += v->lazy;
v->right->lazy += v->lazy;
}
v->lazy = 0;
}
void init() {
root = createNode();
}
void update( node *v, long long l, long long r, long long lu, long long ru, long long x ) {
if ( l != r ) {
if ( v->left == NULL )
v->left = createNode();
if ( v->right == NULL )
v->right = createNode();
}
propag( v, l, r );
if ( lu > r || ru < l )
return;
if ( lu <= l && r <= ru ) {
v->lazy += x;
propag( v, l, r );
return;
}
int mid = (l + r) / 2;
update( v->left, l, mid, lu, ru, x );
update( v->right, mid + 1, r, lu, ru, x );
v->minn = min( v->left->minn, v->right->minn );
}
void update( long long l, long long r, long long x ) {
update( root, 0, MAX_M, l, r, x );
}
long long queryALL() {
return root->minn;
}
};
SegTree aint;
void update( int event, long long x ) {
aint.update( x, MAX_M, event * 2 * x );
aint.update( x - 1, MAX_M, -event * x );
}
bool init( int n, long long m, long long c[] ) {
aint.init();
for ( int i = 0; i < n; i++ )
update( 1, c[i] );
return (aint.queryALL() >= -1);
}
bool is_happy( int event, int n, long long c[] ) {
for ( int i = 0; i < n; i++ )
update( event, c[i] );
return (aint.queryALL() >= -1);
}
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 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |