# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
602301 | 2022-07-22T20:56:31 Z | IvanJ | Self Study (JOI22_ho_t2) | C++17 | 253 ms | 11436 KB |
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 3e5 + 5; int n; ll m; ll A[maxn], B[maxn]; int check(ll x) { ll ret = 0; for(int i = 0;i < n;i++) { ll a = max(A[i], B[i]) * m; if(x > a) ret -= (x - a + B[i] - 1) / B[i]; else ret += (a - x) / max(A[i], B[i]); if(-ret > n * m) return 0; } return (ret >= 0); } int main() { scanf("%d%lld", &n, &m); for(int i = 0;i < n;i++) scanf("%lld", A + i); for(int i = 0;i < n;i++) scanf("%lld", B + i); ll lo = 0, hi = 1e18, ans = -1; while(lo <= hi) { ll mid = (lo + hi) / 2; if(check(mid)) ans = mid, lo = mid + 1; else hi = mid - 1; } printf("%lld\n", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | 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 | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 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 | 104 ms | 4976 KB | Output is correct |
12 | Correct | 109 ms | 4984 KB | Output is correct |
13 | Correct | 94 ms | 4968 KB | Output is correct |
14 | Correct | 72 ms | 4972 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 41 ms | 4940 KB | Output is correct |
17 | Correct | 103 ms | 4976 KB | Output is correct |
18 | Correct | 106 ms | 4884 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 41 ms | 4940 KB | Output is correct |
3 | Correct | 103 ms | 4976 KB | Output is correct |
4 | Correct | 106 ms | 4884 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 | 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 | 48 ms | 2640 KB | Output is correct |
14 | Correct | 33 ms | 1896 KB | Output is correct |
15 | Correct | 25 ms | 1568 KB | Output is correct |
16 | Correct | 21 ms | 1364 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 0 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 | 2 ms | 432 KB | Output is correct |
23 | Correct | 2 ms | 468 KB | Output is correct |
# | Verdict | Execution time | Memory | 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 | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 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 | 104 ms | 4976 KB | Output is correct |
12 | Correct | 109 ms | 4984 KB | Output is correct |
13 | Correct | 94 ms | 4968 KB | Output is correct |
14 | Correct | 72 ms | 4972 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 | 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 | 48 ms | 2640 KB | Output is correct |
24 | Correct | 33 ms | 1896 KB | Output is correct |
25 | Correct | 25 ms | 1568 KB | Output is correct |
26 | Correct | 21 ms | 1364 KB | Output is correct |
27 | Correct | 1 ms | 212 KB | Output is correct |
28 | Correct | 0 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 | 2 ms | 432 KB | Output is correct |
33 | Correct | 2 ms | 468 KB | Output is correct |
34 | Correct | 0 ms | 212 KB | Output is correct |
35 | Correct | 41 ms | 4940 KB | Output is correct |
36 | Correct | 103 ms | 4976 KB | Output is correct |
37 | Correct | 106 ms | 4884 KB | Output is correct |
38 | Correct | 1 ms | 212 KB | Output is correct |
39 | Correct | 1 ms | 308 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 | 308 KB | Output is correct |
43 | Correct | 0 ms | 212 KB | Output is correct |
44 | Correct | 0 ms | 212 KB | Output is correct |
45 | Correct | 2 ms | 448 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 | 0 ms | 212 KB | Output is correct |
50 | Correct | 1 ms | 212 KB | Output is correct |
51 | Correct | 2 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 | 67 ms | 5452 KB | Output is correct |
56 | Correct | 33 ms | 3084 KB | Output is correct |
57 | Correct | 27 ms | 3132 KB | Output is correct |
# | Verdict | Execution time | Memory | 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 | 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 | 48 ms | 2640 KB | Output is correct |
10 | Correct | 33 ms | 1896 KB | Output is correct |
11 | Correct | 25 ms | 1568 KB | Output is correct |
12 | Correct | 21 ms | 1364 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 0 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 | 2 ms | 432 KB | Output is correct |
19 | Correct | 2 ms | 468 KB | Output is correct |
20 | Correct | 0 ms | 212 KB | Output is correct |
21 | Correct | 41 ms | 4940 KB | Output is correct |
22 | Correct | 103 ms | 4976 KB | Output is correct |
23 | Correct | 106 ms | 4884 KB | Output is correct |
24 | Correct | 39 ms | 1816 KB | Output is correct |
25 | Correct | 73 ms | 5036 KB | Output is correct |
26 | Correct | 13 ms | 1404 KB | Output is correct |
27 | Correct | 110 ms | 10704 KB | Output is correct |
28 | Correct | 110 ms | 10700 KB | Output is correct |
29 | Correct | 113 ms | 10784 KB | Output is correct |
30 | Correct | 146 ms | 10796 KB | Output is correct |
31 | Correct | 225 ms | 10780 KB | Output is correct |
32 | Correct | 103 ms | 6156 KB | Output is correct |
33 | Correct | 169 ms | 11436 KB | Output is correct |
34 | Correct | 111 ms | 6152 KB | Output is correct |
# | Verdict | Execution time | Memory | 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 | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 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 | 104 ms | 4976 KB | Output is correct |
12 | Correct | 109 ms | 4984 KB | Output is correct |
13 | Correct | 94 ms | 4968 KB | Output is correct |
14 | Correct | 72 ms | 4972 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 | 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 | 48 ms | 2640 KB | Output is correct |
24 | Correct | 33 ms | 1896 KB | Output is correct |
25 | Correct | 25 ms | 1568 KB | Output is correct |
26 | Correct | 21 ms | 1364 KB | Output is correct |
27 | Correct | 1 ms | 212 KB | Output is correct |
28 | Correct | 0 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 | 2 ms | 432 KB | Output is correct |
33 | Correct | 2 ms | 468 KB | Output is correct |
34 | Correct | 1 ms | 212 KB | Output is correct |
35 | Correct | 1 ms | 308 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 | 308 KB | Output is correct |
39 | Correct | 0 ms | 212 KB | Output is correct |
40 | Correct | 0 ms | 212 KB | Output is correct |
41 | Correct | 2 ms | 448 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 | 0 ms | 212 KB | Output is correct |
46 | Correct | 1 ms | 212 KB | Output is correct |
47 | Correct | 2 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 | 67 ms | 5452 KB | Output is correct |
52 | Correct | 33 ms | 3084 KB | Output is correct |
53 | Correct | 27 ms | 3132 KB | Output is correct |
54 | Correct | 39 ms | 1816 KB | Output is correct |
55 | Correct | 73 ms | 5036 KB | Output is correct |
56 | Correct | 13 ms | 1404 KB | Output is correct |
57 | Correct | 110 ms | 10704 KB | Output is correct |
58 | Correct | 110 ms | 10700 KB | Output is correct |
59 | Correct | 113 ms | 10784 KB | Output is correct |
60 | Correct | 146 ms | 10796 KB | Output is correct |
61 | Correct | 225 ms | 10780 KB | Output is correct |
62 | Correct | 103 ms | 6156 KB | Output is correct |
63 | Correct | 169 ms | 11436 KB | Output is correct |
64 | Correct | 111 ms | 6152 KB | Output is correct |
65 | Correct | 0 ms | 212 KB | Output is correct |
66 | Correct | 41 ms | 4940 KB | Output is correct |
67 | Correct | 103 ms | 4976 KB | Output is correct |
68 | Correct | 106 ms | 4884 KB | Output is correct |
69 | Correct | 21 ms | 1352 KB | Output is correct |
70 | Correct | 6 ms | 468 KB | Output is correct |
71 | Correct | 0 ms | 212 KB | Output is correct |
72 | Correct | 33 ms | 1744 KB | Output is correct |
73 | Correct | 9 ms | 596 KB | Output is correct |
74 | Correct | 1 ms | 340 KB | Output is correct |
75 | Correct | 106 ms | 10788 KB | Output is correct |
76 | Correct | 124 ms | 10676 KB | Output is correct |
77 | Correct | 158 ms | 10700 KB | Output is correct |
78 | Correct | 166 ms | 10780 KB | Output is correct |
79 | Correct | 211 ms | 10828 KB | Output is correct |
80 | Correct | 253 ms | 10728 KB | Output is correct |
81 | Correct | 157 ms | 8900 KB | Output is correct |
82 | Correct | 152 ms | 8800 KB | Output is correct |