답안 #1086716

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1086716 2024-09-11T10:13:36 Z LOLOLO Happiness (Balkan15_HAPPINESS) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include <happiness.h>
using namespace std;
typedef long long ll;

#define           s     second
#define           f     first
#define           pb    push_back
#define           ep    emplace
#define           eb    emplace_back
#define           lb    lower_bound
#define           ub    upper_bound
#define       all(x)    x.begin(), x.end()
#define      rall(x)    x.rbegin(), x.rend()
#define   uniquev(v)    sort(all(v)), (v).resize(unique(all(v)) - (v).begin())
#define     mem(f,x)    memset(f , x , sizeof(f))
#define        sz(x)    (int)(x).size()
#define  __lcm(a, b)    (1ll * ((a) / __gcd((a), (b))) * (b))
#define          mxx    *max_element
#define          mnn    *min_element
#define    cntbit(x)    __builtin_popcountll(x)
#define       len(x)    (int)(x.length())
 
const int N = 1e6 + 10;
ll sum[40];
multiset <ll> save[40];

void add(ll x, int c) {
    int p = 0;
    while ((ll)1 << (p + 1) <= x) {
        p++;
    }

    if (c == 1) {
        sum[p] += x;
        save[p].insert(x);
    } else {
        sum[p] -= x;
        save[p].erase(save[p].find(x));
    }
}

bool ok() {
    ll cur = sum[0];
    for (int i = 0; i < 40; i++) {
        if (save[i].empty())
            continue;

        auto it = save[i].begin();
        ll val = *it;
        if (cur + 1 < val)
            return 0;

        if (sz(save[i]) >= 2) {
            it = next(it);
            if (cur + val + 1 < *it)
                return 0;
        }

        cur += sum[i];
    }

    return 1;
}

bool init(int n, ll mx, ll coin[]) {
    for (int i = 0; i < n; i++) {
        add(coin[i], 1);
    }

    return ok();
}

bool is_happy(int c, int n, long long coin[]) {
    for (int i = 0; i < n; ++i) {
        add(coin[i], c);
    }

    return ok();
}

int main() {

}

Compilation message

grader.cpp: In function 'int main()':
grader.cpp:16:12: warning: unused variable 'max_code' [-Wunused-variable]
   16 |  long long max_code;
      |            ^~~~~~~~
/usr/bin/ld: /tmp/ccIrvOZv.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccF1jR4s.o:happiness.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status