Submission #973540

# Submission time Handle Problem Language Result Execution time Memory
973540 2024-05-02T06:59:16 Z berr Self Study (JOI22_ho_t2) C++17
100 / 100
221 ms 11604 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
 
 
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
 
    int n, m; cin >> n >> m;
    vector<int> a(n), b(n);

    for(auto &i: a) cin >> i;
    for(auto &i: b) cin >> i;

    auto check=[&](int x){
        int bos=0;
        for(int i=0; i<n; i++){
            if(a[i]<=b[i]){
                bos+=m;
                bos-=(x+b[i]-1)/b[i];
            }
            else{
                if(m*a[i]>=x){
                    bos+=m-(x+a[i]-1)/a[i];
                }
                else{
                    bos-=(x-m*a[i]+b[i]-1)/b[i];
                }
            }
            if(-bos > (n-i)*m) return 0LL;
        }
        if(bos < 0) return 0LL;
        return 1LL;
    };
    int s=0;

    for(int i=60; i>=0; i--){
        int tmp = s+(1LL<<i);
       // cout<<tmp<<"\n";
        if(check(tmp)) s=tmp;
    }

    cout<<s;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 604 KB Output is correct
11 Correct 88 ms 10908 KB Output is correct
12 Correct 90 ms 10832 KB Output is correct
13 Correct 65 ms 8852 KB Output is correct
14 Correct 54 ms 8800 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 27 ms 6316 KB Output is correct
17 Correct 77 ms 11424 KB Output is correct
18 Correct 81 ms 10888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 27 ms 6316 KB Output is correct
3 Correct 77 ms 11424 KB Output is correct
4 Correct 81 ms 10888 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 456 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 504 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 43 ms 5460 KB Output is correct
14 Correct 29 ms 3812 KB Output is correct
15 Correct 22 ms 2908 KB Output is correct
16 Correct 18 ms 2392 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 600 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 2 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 604 KB Output is correct
11 Correct 88 ms 10908 KB Output is correct
12 Correct 90 ms 10832 KB Output is correct
13 Correct 65 ms 8852 KB Output is correct
14 Correct 54 ms 8800 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 456 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 504 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 43 ms 5460 KB Output is correct
24 Correct 29 ms 3812 KB Output is correct
25 Correct 22 ms 2908 KB Output is correct
26 Correct 18 ms 2392 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 600 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 2 ms 632 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 27 ms 6316 KB Output is correct
36 Correct 77 ms 11424 KB Output is correct
37 Correct 81 ms 10888 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 2 ms 640 KB Output is correct
46 Correct 3 ms 604 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 17 ms 2256 KB Output is correct
49 Correct 1 ms 348 KB Output is correct
50 Correct 0 ms 456 KB Output is correct
51 Correct 2 ms 600 KB Output is correct
52 Correct 0 ms 348 KB Output is correct
53 Correct 0 ms 348 KB Output is correct
54 Correct 0 ms 348 KB Output is correct
55 Correct 47 ms 5468 KB Output is correct
56 Correct 25 ms 3160 KB Output is correct
57 Correct 19 ms 3164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 456 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 504 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 43 ms 5460 KB Output is correct
10 Correct 29 ms 3812 KB Output is correct
11 Correct 22 ms 2908 KB Output is correct
12 Correct 18 ms 2392 KB Output is correct
13 Correct 1 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 600 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 2 ms 632 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 27 ms 6316 KB Output is correct
22 Correct 77 ms 11424 KB Output is correct
23 Correct 81 ms 10888 KB Output is correct
24 Correct 26 ms 1884 KB Output is correct
25 Correct 62 ms 5116 KB Output is correct
26 Correct 11 ms 1492 KB Output is correct
27 Correct 80 ms 10768 KB Output is correct
28 Correct 85 ms 10952 KB Output is correct
29 Correct 86 ms 10952 KB Output is correct
30 Correct 113 ms 11280 KB Output is correct
31 Correct 184 ms 10948 KB Output is correct
32 Correct 106 ms 6228 KB Output is correct
33 Correct 221 ms 11604 KB Output is correct
34 Correct 106 ms 6320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 604 KB Output is correct
11 Correct 88 ms 10908 KB Output is correct
12 Correct 90 ms 10832 KB Output is correct
13 Correct 65 ms 8852 KB Output is correct
14 Correct 54 ms 8800 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 456 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 504 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 43 ms 5460 KB Output is correct
24 Correct 29 ms 3812 KB Output is correct
25 Correct 22 ms 2908 KB Output is correct
26 Correct 18 ms 2392 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 600 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 2 ms 632 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 2 ms 640 KB Output is correct
42 Correct 3 ms 604 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 17 ms 2256 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 0 ms 456 KB Output is correct
47 Correct 2 ms 600 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 47 ms 5468 KB Output is correct
52 Correct 25 ms 3160 KB Output is correct
53 Correct 19 ms 3164 KB Output is correct
54 Correct 26 ms 1884 KB Output is correct
55 Correct 62 ms 5116 KB Output is correct
56 Correct 11 ms 1492 KB Output is correct
57 Correct 80 ms 10768 KB Output is correct
58 Correct 85 ms 10952 KB Output is correct
59 Correct 86 ms 10952 KB Output is correct
60 Correct 113 ms 11280 KB Output is correct
61 Correct 184 ms 10948 KB Output is correct
62 Correct 106 ms 6228 KB Output is correct
63 Correct 221 ms 11604 KB Output is correct
64 Correct 106 ms 6320 KB Output is correct
65 Correct 1 ms 348 KB Output is correct
66 Correct 27 ms 6316 KB Output is correct
67 Correct 77 ms 11424 KB Output is correct
68 Correct 81 ms 10888 KB Output is correct
69 Correct 19 ms 1368 KB Output is correct
70 Correct 5 ms 604 KB Output is correct
71 Correct 0 ms 348 KB Output is correct
72 Correct 28 ms 1752 KB Output is correct
73 Correct 6 ms 604 KB Output is correct
74 Correct 1 ms 348 KB Output is correct
75 Correct 93 ms 10776 KB Output is correct
76 Correct 103 ms 11200 KB Output is correct
77 Correct 109 ms 10836 KB Output is correct
78 Correct 140 ms 10952 KB Output is correct
79 Correct 190 ms 10956 KB Output is correct
80 Correct 200 ms 10952 KB Output is correct
81 Correct 198 ms 8784 KB Output is correct
82 Correct 145 ms 8964 KB Output is correct