답안 #658840

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
658840 2022-11-15T03:25:46 Z GrandTiger1729 Self Study (JOI22_ho_t2) C++17
100 / 100
249 ms 11452 KB
#include <iostream>
using namespace std;

const long long INF = 5e18;
int main(){
    cin.tie(0)->sync_with_stdio(0);
    long long n, m; cin >> n >> m;
    long long a[n], b[n];
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    for (int i = 0; i < n; i++){
        cin >> b[i];
    }
    auto check = [&](long long x) -> bool {
        long long cnt = 0;
        for (int i = 0; i < n; i++){
            if (a[i] > b[i]){
                if (a[i] * m >= x){
                    cnt += x / a[i] + (bool)(x % a[i]);
                }else{
                    cnt += m;
                    long long y = x - m * a[i];
                    cnt += y / b[i] + (bool)(y % b[i]);
                }
            }else{
                cnt += x / b[i] + (bool)(x % b[i]);
            }
            if (cnt > n * m){
                return false;
            }
        }
        return true;
    };
    long long l = 0, r = INF;
    while (l < r - 1){
        long long mid = (l + r) / 2;
        if (check(mid)){
            l = mid;
        }else{
            r = mid;
        }
    }
    cout << l;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 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 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 101 ms 4948 KB Output is correct
12 Correct 123 ms 5000 KB Output is correct
13 Correct 90 ms 4996 KB Output is correct
14 Correct 81 ms 4948 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 35 ms 6144 KB Output is correct
17 Correct 115 ms 11384 KB Output is correct
18 Correct 98 ms 10748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 35 ms 6144 KB Output is correct
3 Correct 115 ms 11384 KB Output is correct
4 Correct 98 ms 10748 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 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 46 ms 2644 KB Output is correct
14 Correct 31 ms 1876 KB Output is correct
15 Correct 23 ms 1484 KB Output is correct
16 Correct 20 ms 1256 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 3 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 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 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 101 ms 4948 KB Output is correct
12 Correct 123 ms 5000 KB Output is correct
13 Correct 90 ms 4996 KB Output is correct
14 Correct 81 ms 4948 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 46 ms 2644 KB Output is correct
24 Correct 31 ms 1876 KB Output is correct
25 Correct 23 ms 1484 KB Output is correct
26 Correct 20 ms 1256 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 3 ms 468 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 35 ms 6144 KB Output is correct
36 Correct 115 ms 11384 KB Output is correct
37 Correct 98 ms 10748 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 324 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 1 ms 320 KB Output is correct
45 Correct 3 ms 468 KB Output is correct
46 Correct 3 ms 596 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 19 ms 1984 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 320 KB Output is correct
51 Correct 2 ms 468 KB Output is correct
52 Correct 1 ms 212 KB Output is correct
53 Correct 0 ms 212 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 58 ms 5440 KB Output is correct
56 Correct 32 ms 3152 KB Output is correct
57 Correct 28 ms 3012 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 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 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 46 ms 2644 KB Output is correct
10 Correct 31 ms 1876 KB Output is correct
11 Correct 23 ms 1484 KB Output is correct
12 Correct 20 ms 1256 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 3 ms 468 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 35 ms 6144 KB Output is correct
22 Correct 115 ms 11384 KB Output is correct
23 Correct 98 ms 10748 KB Output is correct
24 Correct 29 ms 1868 KB Output is correct
25 Correct 71 ms 4956 KB Output is correct
26 Correct 13 ms 1364 KB Output is correct
27 Correct 96 ms 10752 KB Output is correct
28 Correct 101 ms 10744 KB Output is correct
29 Correct 103 ms 10744 KB Output is correct
30 Correct 121 ms 10792 KB Output is correct
31 Correct 202 ms 10748 KB Output is correct
32 Correct 118 ms 6140 KB Output is correct
33 Correct 249 ms 11452 KB Output is correct
34 Correct 117 ms 6160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 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 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 101 ms 4948 KB Output is correct
12 Correct 123 ms 5000 KB Output is correct
13 Correct 90 ms 4996 KB Output is correct
14 Correct 81 ms 4948 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 46 ms 2644 KB Output is correct
24 Correct 31 ms 1876 KB Output is correct
25 Correct 23 ms 1484 KB Output is correct
26 Correct 20 ms 1256 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 3 ms 468 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 324 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 320 KB Output is correct
41 Correct 3 ms 468 KB Output is correct
42 Correct 3 ms 596 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 19 ms 1984 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 1 ms 320 KB Output is correct
47 Correct 2 ms 468 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 58 ms 5440 KB Output is correct
52 Correct 32 ms 3152 KB Output is correct
53 Correct 28 ms 3012 KB Output is correct
54 Correct 29 ms 1868 KB Output is correct
55 Correct 71 ms 4956 KB Output is correct
56 Correct 13 ms 1364 KB Output is correct
57 Correct 96 ms 10752 KB Output is correct
58 Correct 101 ms 10744 KB Output is correct
59 Correct 103 ms 10744 KB Output is correct
60 Correct 121 ms 10792 KB Output is correct
61 Correct 202 ms 10748 KB Output is correct
62 Correct 118 ms 6140 KB Output is correct
63 Correct 249 ms 11452 KB Output is correct
64 Correct 117 ms 6160 KB Output is correct
65 Correct 0 ms 212 KB Output is correct
66 Correct 35 ms 6144 KB Output is correct
67 Correct 115 ms 11384 KB Output is correct
68 Correct 98 ms 10748 KB Output is correct
69 Correct 21 ms 1444 KB Output is correct
70 Correct 6 ms 596 KB Output is correct
71 Correct 0 ms 212 KB Output is correct
72 Correct 32 ms 1800 KB Output is correct
73 Correct 8 ms 664 KB Output is correct
74 Correct 1 ms 336 KB Output is correct
75 Correct 113 ms 10740 KB Output is correct
76 Correct 125 ms 10732 KB Output is correct
77 Correct 123 ms 10740 KB Output is correct
78 Correct 152 ms 10804 KB Output is correct
79 Correct 212 ms 10788 KB Output is correct
80 Correct 231 ms 10796 KB Output is correct
81 Correct 230 ms 8812 KB Output is correct
82 Correct 184 ms 8692 KB Output is correct