답안 #532401

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
532401 2022-03-02T20:37:50 Z Marceantasy Self Study (JOI22_ho_t2) C++17
100 / 100
636 ms 11340 KB
#include <bits/stdc++.h>
using namespace std; 

#define ll long long 
#define ar array

const int mxN = 3e5+5, M = 1e9+7;
ll n, m, a[mxN], b[mxN];

bool f(ll val){
    ll ret = 0;
    for(int i = 0; i<n; ++i){
        if(a[i] <= b[i]){
            ret += (val+b[i]-1)/b[i];
        }
        else{
            ll flag = (val+a[i]-1)/a[i];
            flag = min(flag, m);
            ll upd = 1e18;
            for(ll j = max(flag-2, 0ll); j<=flag; ++j){
                ll rem = max(0ll, val - a[i]*j);
                upd = min(upd, j + (rem+b[i]-1)/b[i]);
            }
            ret += upd;
        }
        if(ret > n*m) return 0;
    }
    return 1;

}

int main(){
#ifdef _DEBUG
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
    std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0);

    cin >> n >> m;
    for(int i = 0; i<n; ++i){
        cin >> a[i];
    }
    for(int i = 0; i<n; ++i){
        cin >> b[i];
    }
    ll l = 0, r = 1e18; 
    while(l != r){
        ll m = (l+r+1)/2;
        if(f(m)){
            l = m; 
        }else{
            r = m-1;
        }
    }
    cout << l;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 2 ms 460 KB Output is correct
11 Correct 132 ms 10704 KB Output is correct
12 Correct 140 ms 10708 KB Output is correct
13 Correct 85 ms 8896 KB Output is correct
14 Correct 141 ms 8768 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 31 ms 6212 KB Output is correct
17 Correct 106 ms 11332 KB Output is correct
18 Correct 103 ms 10784 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 31 ms 6212 KB Output is correct
3 Correct 106 ms 11332 KB Output is correct
4 Correct 103 ms 10784 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 0 ms 324 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 48 ms 5444 KB Output is correct
14 Correct 37 ms 3780 KB Output is correct
15 Correct 26 ms 2864 KB Output is correct
16 Correct 21 ms 2348 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 0 ms 320 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 0 ms 320 KB Output is correct
22 Correct 2 ms 332 KB Output is correct
23 Correct 3 ms 452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 2 ms 460 KB Output is correct
11 Correct 132 ms 10704 KB Output is correct
12 Correct 140 ms 10708 KB Output is correct
13 Correct 85 ms 8896 KB Output is correct
14 Correct 141 ms 8768 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 1 ms 320 KB Output is correct
17 Correct 0 ms 324 KB Output is correct
18 Correct 1 ms 320 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 48 ms 5444 KB Output is correct
24 Correct 37 ms 3780 KB Output is correct
25 Correct 26 ms 2864 KB Output is correct
26 Correct 21 ms 2348 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 0 ms 320 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 0 ms 320 KB Output is correct
32 Correct 2 ms 332 KB Output is correct
33 Correct 3 ms 452 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 31 ms 6212 KB Output is correct
36 Correct 106 ms 11332 KB Output is correct
37 Correct 103 ms 10784 KB Output is correct
38 Correct 1 ms 316 KB Output is correct
39 Correct 0 ms 204 KB Output is correct
40 Correct 0 ms 204 KB Output is correct
41 Correct 1 ms 332 KB Output is correct
42 Correct 1 ms 204 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 1 ms 324 KB Output is correct
45 Correct 5 ms 460 KB Output is correct
46 Correct 7 ms 584 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 33 ms 2104 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
50 Correct 1 ms 316 KB Output is correct
51 Correct 3 ms 428 KB Output is correct
52 Correct 1 ms 204 KB Output is correct
53 Correct 0 ms 204 KB Output is correct
54 Correct 1 ms 204 KB Output is correct
55 Correct 77 ms 5488 KB Output is correct
56 Correct 35 ms 3108 KB Output is correct
57 Correct 71 ms 3144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 0 ms 324 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 48 ms 5444 KB Output is correct
10 Correct 37 ms 3780 KB Output is correct
11 Correct 26 ms 2864 KB Output is correct
12 Correct 21 ms 2348 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 ms 320 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 320 KB Output is correct
18 Correct 2 ms 332 KB Output is correct
19 Correct 3 ms 452 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 31 ms 6212 KB Output is correct
22 Correct 106 ms 11332 KB Output is correct
23 Correct 103 ms 10784 KB Output is correct
24 Correct 29 ms 1860 KB Output is correct
25 Correct 75 ms 4988 KB Output is correct
26 Correct 12 ms 1348 KB Output is correct
27 Correct 106 ms 10764 KB Output is correct
28 Correct 97 ms 10760 KB Output is correct
29 Correct 108 ms 10756 KB Output is correct
30 Correct 129 ms 10780 KB Output is correct
31 Correct 202 ms 10672 KB Output is correct
32 Correct 116 ms 6084 KB Output is correct
33 Correct 246 ms 11340 KB Output is correct
34 Correct 122 ms 6280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 2 ms 460 KB Output is correct
11 Correct 132 ms 10704 KB Output is correct
12 Correct 140 ms 10708 KB Output is correct
13 Correct 85 ms 8896 KB Output is correct
14 Correct 141 ms 8768 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 1 ms 320 KB Output is correct
17 Correct 0 ms 324 KB Output is correct
18 Correct 1 ms 320 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 48 ms 5444 KB Output is correct
24 Correct 37 ms 3780 KB Output is correct
25 Correct 26 ms 2864 KB Output is correct
26 Correct 21 ms 2348 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 0 ms 320 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 0 ms 320 KB Output is correct
32 Correct 2 ms 332 KB Output is correct
33 Correct 3 ms 452 KB Output is correct
34 Correct 1 ms 316 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 0 ms 204 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 1 ms 324 KB Output is correct
41 Correct 5 ms 460 KB Output is correct
42 Correct 7 ms 584 KB Output is correct
43 Correct 1 ms 332 KB Output is correct
44 Correct 33 ms 2104 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 1 ms 316 KB Output is correct
47 Correct 3 ms 428 KB Output is correct
48 Correct 1 ms 204 KB Output is correct
49 Correct 0 ms 204 KB Output is correct
50 Correct 1 ms 204 KB Output is correct
51 Correct 77 ms 5488 KB Output is correct
52 Correct 35 ms 3108 KB Output is correct
53 Correct 71 ms 3144 KB Output is correct
54 Correct 29 ms 1860 KB Output is correct
55 Correct 75 ms 4988 KB Output is correct
56 Correct 12 ms 1348 KB Output is correct
57 Correct 106 ms 10764 KB Output is correct
58 Correct 97 ms 10760 KB Output is correct
59 Correct 108 ms 10756 KB Output is correct
60 Correct 129 ms 10780 KB Output is correct
61 Correct 202 ms 10672 KB Output is correct
62 Correct 116 ms 6084 KB Output is correct
63 Correct 246 ms 11340 KB Output is correct
64 Correct 122 ms 6280 KB Output is correct
65 Correct 1 ms 204 KB Output is correct
66 Correct 31 ms 6212 KB Output is correct
67 Correct 106 ms 11332 KB Output is correct
68 Correct 103 ms 10784 KB Output is correct
69 Correct 34 ms 1336 KB Output is correct
70 Correct 9 ms 580 KB Output is correct
71 Correct 1 ms 204 KB Output is correct
72 Correct 51 ms 1732 KB Output is correct
73 Correct 11 ms 672 KB Output is correct
74 Correct 1 ms 332 KB Output is correct
75 Correct 182 ms 10704 KB Output is correct
76 Correct 191 ms 10812 KB Output is correct
77 Correct 204 ms 10660 KB Output is correct
78 Correct 256 ms 10748 KB Output is correct
79 Correct 349 ms 10896 KB Output is correct
80 Correct 351 ms 10784 KB Output is correct
81 Correct 228 ms 8900 KB Output is correct
82 Correct 636 ms 8688 KB Output is correct