답안 #585227

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
585227 2022-06-28T12:53:44 Z rgnerdplayer Self Study (JOI22_ho_t2) C++17
0 / 100
304 ms 8476 KB
#include <bits/stdc++.h>
using namespace std;

using i64 = long long;

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    auto 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];
            a[i] = max(a[i], b[i]);
        }

        i64 lo = 0, hi = 1e18;

        while (lo < hi) {
            i64 md = lo + hi + 1 >> 1;
            i64 cnt = 0;
            
            for (int i = 0; i < n; i++) {
                if (md <= 1LL * m * a[i]) {
                    cnt += (md + a[i] - 1) / a[i];
                } else {
                    cnt += m + (md - 1LL * a[i] * m + b[i] - 1) / b[i];
                }
            }

            if (cnt <= 1LL * n * m) {
                lo = md;
            } else {
                hi = md - 1;
            }
        }

        cout << lo << '\n';
    };
    
    solve();
    
    return 0;
}
 

Compilation message

Main.cpp: In lambda function:
Main.cpp:30:30: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   30 |             i64 md = lo + hi + 1 >> 1;
      |                      ~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 316 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 3 ms 340 KB Output is correct
11 Correct 158 ms 8476 KB Output is correct
12 Correct 177 ms 8408 KB Output is correct
13 Correct 164 ms 6608 KB Output is correct
14 Incorrect 304 ms 6484 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 82 ms 4400 KB Output is correct
10 Correct 56 ms 3028 KB Output is correct
11 Correct 41 ms 2308 KB Output is correct
12 Correct 35 ms 1944 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 316 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Incorrect 6 ms 340 KB Output isn't correct
19 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 0 ms 316 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 3 ms 340 KB Output is correct
11 Correct 158 ms 8476 KB Output is correct
12 Correct 177 ms 8408 KB Output is correct
13 Correct 164 ms 6608 KB Output is correct
14 Incorrect 304 ms 6484 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 82 ms 4400 KB Output is correct
10 Correct 56 ms 3028 KB Output is correct
11 Correct 41 ms 2308 KB Output is correct
12 Correct 35 ms 1944 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 316 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Incorrect 6 ms 340 KB Output isn't correct
19 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 0 ms 316 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 3 ms 340 KB Output is correct
11 Correct 158 ms 8476 KB Output is correct
12 Correct 177 ms 8408 KB Output is correct
13 Correct 164 ms 6608 KB Output is correct
14 Incorrect 304 ms 6484 KB Output isn't correct
15 Halted 0 ms 0 KB -