Submission #803747

# Submission time Handle Problem Language Result Execution time Memory
803747 2023-08-03T05:46:49 Z vjudge1 Self Study (JOI22_ho_t2) C++17
100 / 100
270 ms 5024 KB
#ifdef Home
#define _GLIBCXX_DEBUG
#endif // Home

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

main() {
#ifdef Home
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // Home
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    ll n, m;
    cin >> n >> m;
    vector < ll > A(n), B(n);
    for(auto &i : A) {
        cin >> i;
    }
    for(auto &i : B) {
        cin >> i;
    }
    ll l = 0, r = 2e18, mid, a, b, c;
    for(; l + 1 < r;) {
        mid = (l + r) / 2;
        c = 0;
        for(int i = 0; i < n && c > -(n * m); ++ i) {
            a = mid;
            if(B[i] >= A[i]) {
                c += m - (a + B[i] - 1) / B[i];
            } else {
                b = min(m, (a + A[i] - 1) / A[i]);
                c += m - b;
                a = max(0ll, a - b * A[i]);
                c -= (a + B[i] - 1) / B[i];
            }
        }
        (c < 0 ? r : l) = mid;
    }
    cout << l;
} 

Compilation message

Main.cpp:12:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   12 | main() {
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 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 1 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 1 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 2 ms 340 KB Output is correct
11 Correct 99 ms 5016 KB Output is correct
12 Correct 123 ms 5008 KB Output is correct
13 Correct 84 ms 5012 KB Output is correct
14 Correct 96 ms 4948 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 27 ms 5024 KB Output is correct
17 Correct 112 ms 5004 KB Output is correct
18 Correct 84 ms 5008 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 27 ms 5024 KB Output is correct
3 Correct 112 ms 5004 KB Output is correct
4 Correct 84 ms 5008 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 0 ms 212 KB Output is correct
13 Correct 47 ms 2644 KB Output is correct
14 Correct 29 ms 1876 KB Output is correct
15 Correct 22 ms 1492 KB Output is correct
16 Correct 19 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 1 ms 340 KB Output is correct
23 Correct 2 ms 392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 1 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 1 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 2 ms 340 KB Output is correct
11 Correct 99 ms 5016 KB Output is correct
12 Correct 123 ms 5008 KB Output is correct
13 Correct 84 ms 5012 KB Output is correct
14 Correct 96 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 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 0 ms 212 KB Output is correct
23 Correct 47 ms 2644 KB Output is correct
24 Correct 29 ms 1876 KB Output is correct
25 Correct 22 ms 1492 KB Output is correct
26 Correct 19 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 1 ms 340 KB Output is correct
33 Correct 2 ms 392 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 27 ms 5024 KB Output is correct
36 Correct 112 ms 5004 KB Output is correct
37 Correct 84 ms 5008 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 0 ms 212 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 3 ms 340 KB Output is correct
46 Correct 4 ms 340 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 20 ms 1132 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 2 ms 340 KB Output is correct
52 Correct 0 ms 212 KB Output is correct
53 Correct 0 ms 212 KB Output is correct
54 Correct 0 ms 212 KB Output is correct
55 Correct 55 ms 2644 KB Output is correct
56 Correct 29 ms 1876 KB Output is correct
57 Correct 31 ms 1876 KB Output is correct
# Verdict Execution time Memory 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 0 ms 212 KB Output is correct
9 Correct 47 ms 2644 KB Output is correct
10 Correct 29 ms 1876 KB Output is correct
11 Correct 22 ms 1492 KB Output is correct
12 Correct 19 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 1 ms 340 KB Output is correct
19 Correct 2 ms 392 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 27 ms 5024 KB Output is correct
22 Correct 112 ms 5004 KB Output is correct
23 Correct 84 ms 5008 KB Output is correct
24 Correct 27 ms 1048 KB Output is correct
25 Correct 65 ms 2416 KB Output is correct
26 Correct 11 ms 724 KB Output is correct
27 Correct 80 ms 5004 KB Output is correct
28 Correct 85 ms 4948 KB Output is correct
29 Correct 87 ms 5008 KB Output is correct
30 Correct 108 ms 4948 KB Output is correct
31 Correct 185 ms 5020 KB Output is correct
32 Correct 109 ms 5008 KB Output is correct
33 Correct 212 ms 5008 KB Output is correct
34 Correct 113 ms 4948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 1 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 1 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 2 ms 340 KB Output is correct
11 Correct 99 ms 5016 KB Output is correct
12 Correct 123 ms 5008 KB Output is correct
13 Correct 84 ms 5012 KB Output is correct
14 Correct 96 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 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 0 ms 212 KB Output is correct
23 Correct 47 ms 2644 KB Output is correct
24 Correct 29 ms 1876 KB Output is correct
25 Correct 22 ms 1492 KB Output is correct
26 Correct 19 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 1 ms 340 KB Output is correct
33 Correct 2 ms 392 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 0 ms 212 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
41 Correct 3 ms 340 KB Output is correct
42 Correct 4 ms 340 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 20 ms 1132 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 2 ms 340 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 0 ms 212 KB Output is correct
51 Correct 55 ms 2644 KB Output is correct
52 Correct 29 ms 1876 KB Output is correct
53 Correct 31 ms 1876 KB Output is correct
54 Correct 27 ms 1048 KB Output is correct
55 Correct 65 ms 2416 KB Output is correct
56 Correct 11 ms 724 KB Output is correct
57 Correct 80 ms 5004 KB Output is correct
58 Correct 85 ms 4948 KB Output is correct
59 Correct 87 ms 5008 KB Output is correct
60 Correct 108 ms 4948 KB Output is correct
61 Correct 185 ms 5020 KB Output is correct
62 Correct 109 ms 5008 KB Output is correct
63 Correct 212 ms 5008 KB Output is correct
64 Correct 113 ms 4948 KB Output is correct
65 Correct 0 ms 212 KB Output is correct
66 Correct 27 ms 5024 KB Output is correct
67 Correct 112 ms 5004 KB Output is correct
68 Correct 84 ms 5008 KB Output is correct
69 Correct 23 ms 724 KB Output is correct
70 Correct 6 ms 340 KB Output is correct
71 Correct 0 ms 212 KB Output is correct
72 Correct 35 ms 980 KB Output is correct
73 Correct 7 ms 468 KB Output is correct
74 Correct 1 ms 212 KB Output is correct
75 Correct 108 ms 4948 KB Output is correct
76 Correct 124 ms 5012 KB Output is correct
77 Correct 133 ms 4948 KB Output is correct
78 Correct 169 ms 5004 KB Output is correct
79 Correct 230 ms 5004 KB Output is correct
80 Correct 270 ms 5008 KB Output is correct
81 Correct 196 ms 4948 KB Output is correct
82 Correct 182 ms 5004 KB Output is correct