답안 #594535

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
594535 2022-07-12T16:11:44 Z Do_you_copy Happiness (Balkan15_HAPPINESS) C++17
10 / 100
508 ms 37328 KB
#include <bits/stdc++.h>
#define taskname "test"
#define fi first
#define se second
#define pb push_back
#define faster ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
using ll = long long;
using pii = pair <int, int>;
using pil = pair <int, ll>;
using pli = pair <ll, int>;
using pll = pair <ll, ll>;
using ull = unsigned ll;
mt19937 Rand(chrono::steady_clock::now().time_since_epoch().count());

ll min(const ll &a, const ll &b){
    return (a < b) ? a : b;
}

ll max(const ll &a, const ll &b){
    return (a > b) ? a : b;
}

//const ll Mod = 1000000009;
//const ll Mod2 = 999999999989;
//only use when required
const int maxN = 1e5 + 1;
const ll inf = 1e12;
int n;
int a[maxN];
int node_cnt = 1;

struct TNode{
    TNode *lp, *rp;
    int val;
    TNode() : lp(nullptr), rp(nullptr), val(0){}
    void update(TNode* id, int i, int v, ll l = 1, ll r = inf){
        if (i < l || i > r) return;
        id->val += v;
        if (l == r){
            return;
        }
        id->create_node();
        ll mid = (l + r) / 2;
        update(id->lp, i, v, l, mid);
        update(id->rp, i, v, mid + 1, r);
    }
    void create_node(){
        if (!lp) lp = new TNode();
        if (!rp) rp = new TNode();
    }
    ll get(TNode* id, int i, int j, ll l = 1, ll r = inf){
        if (r < i || l > j) return 0;
        if (i <= l && r <= j) return id->val;
        ll mid = (l + r) / 2;
        ll ret = 0;
        if (id->lp) ret += get(id->lp, i, j, l, mid);
        if (id->rp) ret += get(id->rp, i, j, mid + 1, r);
        return ret;
    }
};

TNode* st;

bool check(){
    ll tem = 1, last = st->val;
    while (tem < last){
        ll t = st->get(st, 1, tem);
        if (t < tem) return 0;
        tem = t + 1;
    }
    return 1;
}

bool init(int N, ll M, ll a[]){
    n = N;
    st = new TNode();
    for (int i = 0; i < n; ++i) st->update(st, a[i], a[i]);
    return check();
}

bool is_happy(int t, int K, ll a[]){
    for (int i = 0; i < K; ++i) st->update(st, a[i], a[i] * t);
    return check();
}

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 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Incorrect 2 ms 972 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Incorrect 508 ms 37328 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Incorrect 2 ms 972 KB Output isn't correct
7 Halted 0 ms 0 KB -