답안 #941112

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
941112 2024-03-08T07:22:17 Z Pring Self Study (JOI22_ho_t2) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

#ifdef MIKU
const string dbmc = "\033[1;38;2;57;197;187m", dbrs = "\033[0m";
#define debug(x...) cout << dbmc << "[" << #x << "]: ", dout(x)
void dout() { cout << dbrs << endl; }
template <typename T, typename ...U>
void dout(T t, U ...u) { cout << t << (sizeof...(u) ? ", " : ""); dout(u...); }
#else
#define dout(...) 39
#endif

#define int long long
#define fs first
#define sc second
#define mp make_pair
#define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++)
typedef pair<int, int> pii;

const int MXN = 300005, INF = 3.9e18;
int n, m, a[MXN], b[MXN];

__int128_t DC(__int128_t a, __int128_t b) {
    if (a == 0) return 0;
    return (a - 1) / b + 1;
}

bool check(__int128_t x) {
    auto f = [&](__int128 x, int a, int b) -> __int128_t {
        if (DC(x, a) <= m) return m - DC(x, a);
        x -= a * m;
        return -DC(x, b);
    };
    __int128_t now = 0;
    FOR(i, 0, n) {
        if (a[i] > b[i]) now += f(x, a[i], b[i]);
        else {
            now += m;
            now -= DC(x, b[i]);
        }
    }
    return (now >= 0);
}

int miku() {
    cin >> n >> m;
    FOR(i, 0, n) cin >> a[i];
    FOR(i, 0, n) cin >> b[i];
    __int128_t l = 0, r = INF;
    r *= INF;
    while (l + 1 < r) {
        __int128_t mid = (l + r) / 2;
        (check(mid) ? l : r) = mid;
    }
    return l;
}

int check() {
    int ans = LLONG_MAX;
    FOR(i, 0, n) ans = min(ans, max(a[i], b[i]));
    return ans;
}

void PRINT() {
    debug();
    cout << n << ' ' << m << '\n';
    FOR(i, 0, n) cout << a[i] << ' ';
    cout << '\n';
    FOR(i, 0, n) cout << b[i] << ' ';
    cout << '\n';
}

int32_t main() {
    cin.tie(0) -> sync_with_stdio(false);
    cin.exceptions(cin.failbit);
    // cout << miku() << '\n';
    int t;
    cin >> t;
    while (t--) {
        int x = miku();
        int y = check();
        if (x != y) {
            PRINT();
            return 0;
        }
    }
    return 0;
}

Compilation message

Main.cpp: In function 'void PRINT()':
Main.cpp:66:5: error: 'debug' was not declared in this scope
   66 |     debug();
      |     ^~~~~