답안 #734418

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
734418 2023-05-02T11:32:30 Z Josia Self Study (JOI22_ho_t2) C++17
100 / 100
385 ms 11580 KB
#include <bits/stdc++.h>

using namespace std;

#define int uint64_t

int n, m;

bool check(int pos, vector<int>&a, vector<int>&b) {
    int free = 0;
    int req = 0;

    for (int i=0; i<n; i++) {
        int thisNeedsFromA = (pos+a[i]-1)/a[i];

        if (thisNeedsFromA <= m) {
            free += m-thisNeedsFromA;
        }
        else {
            req += (pos-a[i]*m + b[i]-1)/b[i];
        }
    }

    return free >= req;
}



signed main() {
    cin.tie(0);
    ios_base::sync_with_stdio(0);

    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];

    for (int i = 0; i<n; i++) a[i] = max(a[i], b[i]);



    int l = 0, r = 2e18;

    while (l < r) {
        int pos = l + (r-l+1) / 2;

        if (check(pos, a, b)) {
            l = pos;
        } else {
            r = pos-1;
        }
    }


    cout << l << "\n";


    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 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 4 ms 340 KB Output is correct
11 Correct 223 ms 5016 KB Output is correct
12 Correct 224 ms 4948 KB Output is correct
13 Correct 237 ms 5004 KB Output is correct
14 Correct 294 ms 5004 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 363 ms 4948 KB Output is correct
17 Correct 275 ms 5020 KB Output is correct
18 Correct 241 ms 5068 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 363 ms 4948 KB Output is correct
3 Correct 275 ms 5020 KB Output is correct
4 Correct 241 ms 5068 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 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 1 ms 212 KB Output is correct
13 Correct 114 ms 2664 KB Output is correct
14 Correct 77 ms 1896 KB Output is correct
15 Correct 57 ms 1492 KB Output is correct
16 Correct 49 ms 1236 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 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 6 ms 340 KB Output is correct
23 Correct 5 ms 468 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 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 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 4 ms 340 KB Output is correct
11 Correct 223 ms 5016 KB Output is correct
12 Correct 224 ms 4948 KB Output is correct
13 Correct 237 ms 5004 KB Output is correct
14 Correct 294 ms 5004 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 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 212 KB Output is correct
23 Correct 114 ms 2664 KB Output is correct
24 Correct 77 ms 1896 KB Output is correct
25 Correct 57 ms 1492 KB Output is correct
26 Correct 49 ms 1236 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 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 6 ms 340 KB Output is correct
33 Correct 5 ms 468 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 363 ms 4948 KB Output is correct
36 Correct 275 ms 5020 KB Output is correct
37 Correct 241 ms 5068 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 320 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 212 KB Output is correct
43 Correct 1 ms 316 KB Output is correct
44 Correct 1 ms 320 KB Output is correct
45 Correct 5 ms 468 KB Output is correct
46 Correct 9 ms 632 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 46 ms 2112 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 5 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 117 ms 5524 KB Output is correct
56 Correct 89 ms 3288 KB Output is correct
57 Correct 100 ms 3160 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 1 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 114 ms 2664 KB Output is correct
10 Correct 77 ms 1896 KB Output is correct
11 Correct 57 ms 1492 KB Output is correct
12 Correct 49 ms 1236 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 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 6 ms 340 KB Output is correct
19 Correct 5 ms 468 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 363 ms 4948 KB Output is correct
22 Correct 275 ms 5020 KB Output is correct
23 Correct 241 ms 5068 KB Output is correct
24 Correct 38 ms 1944 KB Output is correct
25 Correct 114 ms 4980 KB Output is correct
26 Correct 27 ms 1356 KB Output is correct
27 Correct 242 ms 10772 KB Output is correct
28 Correct 239 ms 10820 KB Output is correct
29 Correct 262 ms 10888 KB Output is correct
30 Correct 239 ms 10824 KB Output is correct
31 Correct 228 ms 10816 KB Output is correct
32 Correct 354 ms 6220 KB Output is correct
33 Correct 350 ms 11580 KB Output is correct
34 Correct 381 ms 6100 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 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 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 4 ms 340 KB Output is correct
11 Correct 223 ms 5016 KB Output is correct
12 Correct 224 ms 4948 KB Output is correct
13 Correct 237 ms 5004 KB Output is correct
14 Correct 294 ms 5004 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 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 212 KB Output is correct
23 Correct 114 ms 2664 KB Output is correct
24 Correct 77 ms 1896 KB Output is correct
25 Correct 57 ms 1492 KB Output is correct
26 Correct 49 ms 1236 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 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 6 ms 340 KB Output is correct
33 Correct 5 ms 468 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 320 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 212 KB Output is correct
39 Correct 1 ms 316 KB Output is correct
40 Correct 1 ms 320 KB Output is correct
41 Correct 5 ms 468 KB Output is correct
42 Correct 9 ms 632 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 46 ms 2112 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 5 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 117 ms 5524 KB Output is correct
52 Correct 89 ms 3288 KB Output is correct
53 Correct 100 ms 3160 KB Output is correct
54 Correct 38 ms 1944 KB Output is correct
55 Correct 114 ms 4980 KB Output is correct
56 Correct 27 ms 1356 KB Output is correct
57 Correct 242 ms 10772 KB Output is correct
58 Correct 239 ms 10820 KB Output is correct
59 Correct 262 ms 10888 KB Output is correct
60 Correct 239 ms 10824 KB Output is correct
61 Correct 228 ms 10816 KB Output is correct
62 Correct 354 ms 6220 KB Output is correct
63 Correct 350 ms 11580 KB Output is correct
64 Correct 381 ms 6100 KB Output is correct
65 Correct 0 ms 212 KB Output is correct
66 Correct 363 ms 4948 KB Output is correct
67 Correct 275 ms 5020 KB Output is correct
68 Correct 241 ms 5068 KB Output is correct
69 Correct 32 ms 1364 KB Output is correct
70 Correct 8 ms 596 KB Output is correct
71 Correct 1 ms 212 KB Output is correct
72 Correct 36 ms 1768 KB Output is correct
73 Correct 9 ms 644 KB Output is correct
74 Correct 1 ms 332 KB Output is correct
75 Correct 242 ms 10760 KB Output is correct
76 Correct 235 ms 10900 KB Output is correct
77 Correct 245 ms 10896 KB Output is correct
78 Correct 245 ms 10820 KB Output is correct
79 Correct 257 ms 10768 KB Output is correct
80 Correct 249 ms 10824 KB Output is correct
81 Correct 331 ms 8844 KB Output is correct
82 Correct 385 ms 8904 KB Output is correct