답안 #884642

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
884642 2023-12-07T20:58:02 Z EJIC_B_KEDAX Self Study (JOI22_ho_t2) C++17
0 / 100
441 ms 7500 KB
#ifdef LOCAL
    //#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#include <random>

#ifndef LOCAL
    //#pragma GCC optimize("O3")
    //#pragma GCC optimize("Ofast")
    //#pragma GCC optimize("unroll-loops")
    #pragma GCC target("avx,avx2,bmi,bmi2,popcnt,lzcnt")
#endif
using namespace std;
using ll = long long;
using ld = long double;
#define x first
#define y second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

mt19937_64 mt(418);

void solve();
void init();

int32_t main() {
#ifndef LOCAL
    cin.tie(nullptr)->sync_with_stdio(false);
#else
    freopen("input.txt", "r", stdin);
#endif
    // srand(time(0));
    init();
    cout << fixed << setprecision(20);
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}

void init() {}

#define int ll

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    ll l = 0, r = 2e18;
    while (r - l > 1) {
        ll mid = (r + l) / 2;
        ll free = (ll)m * n;
        vector<ll> skill(n, 0);
        for (int i = 0; i < n; i++) {
            if (a[i] > b[i]) {
                ll have = (mid + a[i] - 1) / a[i];
                have = min(have, (ll)m);
                skill[i] += a[i] * have;
                free -= have;
            }
        }
        for (int i = 0; i < n; i++) {
            ll need = mid - skill[i];
            if (need > 0) {
                ll have = (need + b[i] - 1) / b[i];
                skill[i] += b[i] * have;
                free -= have;
            }
        }
        if (free >= 0) {
            l = mid;
        } else {
            r = mid;
        }
        // cout << "!!! " << r << ' ' << l << '\n';
    }
    cout << l << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 3 ms 348 KB Output is correct
11 Correct 234 ms 7500 KB Output is correct
12 Correct 237 ms 7468 KB Output is correct
13 Correct 152 ms 7492 KB Output is correct
14 Incorrect 441 ms 7492 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 80 ms 3944 KB Output is correct
10 Correct 53 ms 2796 KB Output is correct
11 Correct 45 ms 2136 KB Output is correct
12 Correct 32 ms 1860 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Incorrect 5 ms 348 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 3 ms 348 KB Output is correct
11 Correct 234 ms 7500 KB Output is correct
12 Correct 237 ms 7468 KB Output is correct
13 Correct 152 ms 7492 KB Output is correct
14 Incorrect 441 ms 7492 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 80 ms 3944 KB Output is correct
10 Correct 53 ms 2796 KB Output is correct
11 Correct 45 ms 2136 KB Output is correct
12 Correct 32 ms 1860 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Incorrect 5 ms 348 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 3 ms 348 KB Output is correct
11 Correct 234 ms 7500 KB Output is correct
12 Correct 237 ms 7468 KB Output is correct
13 Correct 152 ms 7492 KB Output is correct
14 Incorrect 441 ms 7492 KB Output isn't correct
15 Halted 0 ms 0 KB -