답안 #1053803

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1053803 2024-08-11T17:49:36 Z Alebn Self Study (JOI22_ho_t2) C++14
0 / 100
77 ms 7260 KB
#include <bits/stdc++.h>
#define int long long

using namespace std;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(n), arr(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) {
        cin >> b[i];
        arr[i] = m * max(a[i], b[i]);
    }
    int l = 0, r = 1e19, mid, ans = 0;
    while(l <= r) {
        mid = (l + r) / 2;
        int over = 0, under = 0;
        for(int i = 0; i < n; i++) {
            if(arr[i] >= mid) over += (arr[i] - mid) / max(a[i], b[i]);
            else under += (mid - arr[i]) / b[i] + ((mid - arr[i]) % b[i] ? 1 : 0);
        }
        if(over >= under) {
            l = mid + 1;
            ans = mid;
        } else r = mid - 1;
    }
    cout << ans << "\n";
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}

Compilation message

Main.cpp: In function 'void solve()':
Main.cpp:15:20: warning: overflow in conversion from 'double' to 'long long int' changes value from '1.0e+19' to '9223372036854775807' [-Woverflow]
   15 |     int l = 0, r = 1e19, mid, ans = 0;
      |                    ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 348 KB Output is correct
11 Correct 69 ms 7260 KB Output is correct
12 Correct 74 ms 7260 KB Output is correct
13 Correct 64 ms 7260 KB Output is correct
14 Incorrect 77 ms 7260 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 344 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 428 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 36 ms 3992 KB Output is correct
10 Correct 24 ms 2824 KB Output is correct
11 Correct 18 ms 2140 KB Output is correct
12 Correct 14 ms 1880 KB Output is correct
13 Correct 0 ms 348 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 1 ms 348 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 348 KB Output is correct
11 Correct 69 ms 7260 KB Output is correct
12 Correct 74 ms 7260 KB Output is correct
13 Correct 64 ms 7260 KB Output is correct
14 Incorrect 77 ms 7260 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 344 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 428 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 36 ms 3992 KB Output is correct
10 Correct 24 ms 2824 KB Output is correct
11 Correct 18 ms 2140 KB Output is correct
12 Correct 14 ms 1880 KB Output is correct
13 Correct 0 ms 348 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 1 ms 348 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 348 KB Output is correct
11 Correct 69 ms 7260 KB Output is correct
12 Correct 74 ms 7260 KB Output is correct
13 Correct 64 ms 7260 KB Output is correct
14 Incorrect 77 ms 7260 KB Output isn't correct
15 Halted 0 ms 0 KB -