답안 #538087

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
538087 2022-03-16T05:12:03 Z ddy888 Self Study (JOI22_ho_t2) C++17
100 / 100
235 ms 10868 KB
#undef _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long 
#define ll long long 
#define pb push_back
#define fi first
#define si second
#define ar array
typedef pair<int,int> pi;
typedef tuple<int,int,int> ti;  
void debug_out() {cerr<<endl;}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {cerr<<" "<<to_string(H);debug_out(T...);}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)

int N, M;
int A[300010], B[300010];

int good(int x) {
    int cnt = 0ll; 
    for (int i = 1; i <= N; ++i) {
        if (M * A[i] >= x) cnt += (x + A[i] - 1ll) / A[i];
        else {
            cnt += M;
            cnt += (x - M * A[i] + B[i] - 1ll) / B[i];
        }
        if (cnt > M * N) return 0;
    }
    return 1;
}

int32_t main() {
    fast;
    cin >> N >> M;
    for (int i = 1; i <= N; ++i) cin >> A[i];
    for (int i = 1; i <= N; ++i) {
        cin >> B[i];
        A[i] = max(A[i], B[i]);
    }
    int lo = 0, hi = 6e18;
    while (lo + 1 < hi) {
        int mid = (lo + hi) / 2;
        if (good(mid)) lo = mid;
        else hi = mid;
    }
    cout << lo; 
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 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 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 118 ms 5112 KB Output is correct
12 Correct 95 ms 4984 KB Output is correct
13 Correct 85 ms 4908 KB Output is correct
14 Correct 78 ms 4932 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 33 ms 4896 KB Output is correct
17 Correct 122 ms 5424 KB Output is correct
18 Correct 94 ms 5524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 33 ms 4896 KB Output is correct
3 Correct 122 ms 5424 KB Output is correct
4 Correct 94 ms 5524 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 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 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 64 ms 2568 KB Output is correct
14 Correct 43 ms 1824 KB Output is correct
15 Correct 24 ms 1432 KB Output is correct
16 Correct 22 ms 1280 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 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 1 ms 212 KB Output is correct
2 Correct 1 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 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 118 ms 5112 KB Output is correct
12 Correct 95 ms 4984 KB Output is correct
13 Correct 85 ms 4908 KB Output is correct
14 Correct 78 ms 4932 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 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 1 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 64 ms 2568 KB Output is correct
24 Correct 43 ms 1824 KB Output is correct
25 Correct 24 ms 1432 KB Output is correct
26 Correct 22 ms 1280 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 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 1 ms 212 KB Output is correct
35 Correct 33 ms 4896 KB Output is correct
36 Correct 122 ms 5424 KB Output is correct
37 Correct 94 ms 5524 KB Output is correct
38 Correct 1 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 328 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 3 ms 468 KB Output is correct
46 Correct 4 ms 596 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 20 ms 2004 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 3 ms 468 KB Output is correct
52 Correct 1 ms 212 KB Output is correct
53 Correct 1 ms 212 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 56 ms 5468 KB Output is correct
56 Correct 34 ms 3276 KB Output is correct
57 Correct 26 ms 3088 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 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 1 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 64 ms 2568 KB Output is correct
10 Correct 43 ms 1824 KB Output is correct
11 Correct 24 ms 1432 KB Output is correct
12 Correct 22 ms 1280 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 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 1 ms 212 KB Output is correct
21 Correct 33 ms 4896 KB Output is correct
22 Correct 122 ms 5424 KB Output is correct
23 Correct 94 ms 5524 KB Output is correct
24 Correct 30 ms 1940 KB Output is correct
25 Correct 74 ms 4940 KB Output is correct
26 Correct 15 ms 1364 KB Output is correct
27 Correct 118 ms 10764 KB Output is correct
28 Correct 101 ms 10868 KB Output is correct
29 Correct 113 ms 10700 KB Output is correct
30 Correct 147 ms 10700 KB Output is correct
31 Correct 235 ms 10796 KB Output is correct
32 Correct 126 ms 6092 KB Output is correct
33 Correct 215 ms 6860 KB Output is correct
34 Correct 102 ms 6168 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 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 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 118 ms 5112 KB Output is correct
12 Correct 95 ms 4984 KB Output is correct
13 Correct 85 ms 4908 KB Output is correct
14 Correct 78 ms 4932 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 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 1 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 64 ms 2568 KB Output is correct
24 Correct 43 ms 1824 KB Output is correct
25 Correct 24 ms 1432 KB Output is correct
26 Correct 22 ms 1280 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 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 1 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 328 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 3 ms 468 KB Output is correct
42 Correct 4 ms 596 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 20 ms 2004 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 3 ms 468 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 56 ms 5468 KB Output is correct
52 Correct 34 ms 3276 KB Output is correct
53 Correct 26 ms 3088 KB Output is correct
54 Correct 30 ms 1940 KB Output is correct
55 Correct 74 ms 4940 KB Output is correct
56 Correct 15 ms 1364 KB Output is correct
57 Correct 118 ms 10764 KB Output is correct
58 Correct 101 ms 10868 KB Output is correct
59 Correct 113 ms 10700 KB Output is correct
60 Correct 147 ms 10700 KB Output is correct
61 Correct 235 ms 10796 KB Output is correct
62 Correct 126 ms 6092 KB Output is correct
63 Correct 215 ms 6860 KB Output is correct
64 Correct 102 ms 6168 KB Output is correct
65 Correct 1 ms 212 KB Output is correct
66 Correct 33 ms 4896 KB Output is correct
67 Correct 122 ms 5424 KB Output is correct
68 Correct 94 ms 5524 KB Output is correct
69 Correct 25 ms 1448 KB Output is correct
70 Correct 7 ms 612 KB Output is correct
71 Correct 1 ms 212 KB Output is correct
72 Correct 33 ms 1840 KB Output is correct
73 Correct 7 ms 580 KB Output is correct
74 Correct 1 ms 336 KB Output is correct
75 Correct 113 ms 8268 KB Output is correct
76 Correct 127 ms 8332 KB Output is correct
77 Correct 130 ms 8284 KB Output is correct
78 Correct 172 ms 8380 KB Output is correct
79 Correct 227 ms 8384 KB Output is correct
80 Correct 224 ms 8376 KB Output is correct
81 Correct 227 ms 8360 KB Output is correct
82 Correct 170 ms 8296 KB Output is correct