# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
842861 | 2023-09-03T12:23:57 Z | _Avocado_ | Self Study (JOI22_ho_t2) | C++14 | 206 ms | 5160 KB |
#include <bits/stdc++.h> #define int int64_t using namespace std; int n, m; int up(int a, int b){ return (a + (b-1))/b; } const int INF = 1e18+18; int check(int x, auto&a, auto&b){ int sum = 0; for(int i = 0; i<n; ++i){ int days = up(x, a[i]); if(days > INF) return 0; if(sum > n*m - min(m, (int)days)) return 0; sum += min(m, (int)days); if(days > m){ int rest = x - (m*a[i]); int extra_days = up(rest, b[i]); if(extra_days > INF) return 0; if(sum > n*m - extra_days) return 0; sum += extra_days; } } if(sum <= n*m) return 1; return 0; } int bsearch(auto&a, auto&b){ int l = -1; int r = INF; while(r-l > 1){ int x = (r+l)/2; if(check(x, a, b)) l = x; else r = x; } return l; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); //freopen("input.in", "r", stdin); //freopen("output.out", "w", stdout); cin>>n>>m; vector<int>a(n); for(auto&u: a) cin>>u; vector<int>b(n); for(auto&u: b) cin>>u; for(int i = 0; i<n; ++i){ a[i] = max(a[i], b[i]); } cout<<bsearch(a, b); cout<<'\n'; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 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 | 344 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 | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 344 KB | Output is correct |
10 | Correct | 2 ms | 348 KB | Output is correct |
11 | Correct | 95 ms | 5144 KB | Output is correct |
12 | Correct | 81 ms | 4948 KB | Output is correct |
13 | Correct | 79 ms | 4956 KB | Output is correct |
14 | Correct | 58 ms | 5112 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 30 ms | 5120 KB | Output is correct |
17 | Correct | 90 ms | 5140 KB | Output is correct |
18 | Correct | 81 ms | 5120 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 30 ms | 5120 KB | Output is correct |
3 | Correct | 90 ms | 5140 KB | Output is correct |
4 | Correct | 81 ms | 5120 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 344 KB | Output is correct |
8 | Correct | 1 ms | 344 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 44 ms | 2652 KB | Output is correct |
14 | Correct | 32 ms | 2040 KB | Output is correct |
15 | Correct | 21 ms | 1900 KB | Output is correct |
16 | Correct | 25 ms | 1416 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 | 1 ms | 348 KB | Output is correct |
21 | Correct | 0 ms | 348 KB | Output is correct |
22 | Correct | 1 ms | 348 KB | Output is correct |
23 | Correct | 3 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 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 | 344 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 | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 344 KB | Output is correct |
10 | Correct | 2 ms | 348 KB | Output is correct |
11 | Correct | 95 ms | 5144 KB | Output is correct |
12 | Correct | 81 ms | 4948 KB | Output is correct |
13 | Correct | 79 ms | 4956 KB | Output is correct |
14 | Correct | 58 ms | 5112 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 0 ms | 348 KB | Output is correct |
17 | Correct | 1 ms | 344 KB | Output is correct |
18 | Correct | 1 ms | 344 KB | Output is correct |
19 | Correct | 1 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 0 ms | 348 KB | Output is correct |
22 | Correct | 0 ms | 348 KB | Output is correct |
23 | Correct | 44 ms | 2652 KB | Output is correct |
24 | Correct | 32 ms | 2040 KB | Output is correct |
25 | Correct | 21 ms | 1900 KB | Output is correct |
26 | Correct | 25 ms | 1416 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 | 1 ms | 348 KB | Output is correct |
31 | Correct | 0 ms | 348 KB | Output is correct |
32 | Correct | 1 ms | 348 KB | Output is correct |
33 | Correct | 3 ms | 348 KB | Output is correct |
34 | Correct | 0 ms | 348 KB | Output is correct |
35 | Correct | 30 ms | 5120 KB | Output is correct |
36 | Correct | 90 ms | 5140 KB | Output is correct |
37 | Correct | 81 ms | 5120 KB | Output is correct |
38 | Correct | 1 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 | 1 ms | 348 KB | Output is correct |
42 | Correct | 0 ms | 352 KB | Output is correct |
43 | Correct | 0 ms | 348 KB | Output is correct |
44 | Correct | 0 ms | 348 KB | Output is correct |
45 | Correct | 2 ms | 344 KB | Output is correct |
46 | Correct | 3 ms | 344 KB | Output is correct |
47 | Correct | 1 ms | 348 KB | Output is correct |
48 | Correct | 16 ms | 1280 KB | Output is correct |
49 | Correct | 0 ms | 352 KB | Output is correct |
50 | Correct | 0 ms | 348 KB | Output is correct |
51 | Correct | 2 ms | 348 KB | Output is correct |
52 | Correct | 0 ms | 348 KB | Output is correct |
53 | Correct | 0 ms | 356 KB | Output is correct |
54 | Correct | 0 ms | 348 KB | Output is correct |
55 | Correct | 46 ms | 2652 KB | Output is correct |
56 | Correct | 31 ms | 1880 KB | Output is correct |
57 | Correct | 23 ms | 1884 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 344 KB | Output is correct |
4 | Correct | 1 ms | 344 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 44 ms | 2652 KB | Output is correct |
10 | Correct | 32 ms | 2040 KB | Output is correct |
11 | Correct | 21 ms | 1900 KB | Output is correct |
12 | Correct | 25 ms | 1416 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 | 1 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 1 ms | 348 KB | Output is correct |
19 | Correct | 3 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 30 ms | 5120 KB | Output is correct |
22 | Correct | 90 ms | 5140 KB | Output is correct |
23 | Correct | 81 ms | 5120 KB | Output is correct |
24 | Correct | 29 ms | 1112 KB | Output is correct |
25 | Correct | 70 ms | 2396 KB | Output is correct |
26 | Correct | 12 ms | 856 KB | Output is correct |
27 | Correct | 85 ms | 4956 KB | Output is correct |
28 | Correct | 91 ms | 4952 KB | Output is correct |
29 | Correct | 95 ms | 5140 KB | Output is correct |
30 | Correct | 119 ms | 5140 KB | Output is correct |
31 | Correct | 188 ms | 5160 KB | Output is correct |
32 | Correct | 140 ms | 5136 KB | Output is correct |
33 | Incorrect | 206 ms | 4956 KB | Output isn't correct |
34 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 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 | 344 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 | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 344 KB | Output is correct |
10 | Correct | 2 ms | 348 KB | Output is correct |
11 | Correct | 95 ms | 5144 KB | Output is correct |
12 | Correct | 81 ms | 4948 KB | Output is correct |
13 | Correct | 79 ms | 4956 KB | Output is correct |
14 | Correct | 58 ms | 5112 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 0 ms | 348 KB | Output is correct |
17 | Correct | 1 ms | 344 KB | Output is correct |
18 | Correct | 1 ms | 344 KB | Output is correct |
19 | Correct | 1 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 0 ms | 348 KB | Output is correct |
22 | Correct | 0 ms | 348 KB | Output is correct |
23 | Correct | 44 ms | 2652 KB | Output is correct |
24 | Correct | 32 ms | 2040 KB | Output is correct |
25 | Correct | 21 ms | 1900 KB | Output is correct |
26 | Correct | 25 ms | 1416 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 | 1 ms | 348 KB | Output is correct |
31 | Correct | 0 ms | 348 KB | Output is correct |
32 | Correct | 1 ms | 348 KB | Output is correct |
33 | Correct | 3 ms | 348 KB | Output is correct |
34 | Correct | 1 ms | 348 KB | Output is correct |
35 | Correct | 0 ms | 348 KB | Output is correct |
36 | Correct | 1 ms | 348 KB | Output is correct |
37 | Correct | 1 ms | 348 KB | Output is correct |
38 | Correct | 0 ms | 352 KB | Output is correct |
39 | Correct | 0 ms | 348 KB | Output is correct |
40 | Correct | 0 ms | 348 KB | Output is correct |
41 | Correct | 2 ms | 344 KB | Output is correct |
42 | Correct | 3 ms | 344 KB | Output is correct |
43 | Correct | 1 ms | 348 KB | Output is correct |
44 | Correct | 16 ms | 1280 KB | Output is correct |
45 | Correct | 0 ms | 352 KB | Output is correct |
46 | Correct | 0 ms | 348 KB | Output is correct |
47 | Correct | 2 ms | 348 KB | Output is correct |
48 | Correct | 0 ms | 348 KB | Output is correct |
49 | Correct | 0 ms | 356 KB | Output is correct |
50 | Correct | 0 ms | 348 KB | Output is correct |
51 | Correct | 46 ms | 2652 KB | Output is correct |
52 | Correct | 31 ms | 1880 KB | Output is correct |
53 | Correct | 23 ms | 1884 KB | Output is correct |
54 | Correct | 29 ms | 1112 KB | Output is correct |
55 | Correct | 70 ms | 2396 KB | Output is correct |
56 | Correct | 12 ms | 856 KB | Output is correct |
57 | Correct | 85 ms | 4956 KB | Output is correct |
58 | Correct | 91 ms | 4952 KB | Output is correct |
59 | Correct | 95 ms | 5140 KB | Output is correct |
60 | Correct | 119 ms | 5140 KB | Output is correct |
61 | Correct | 188 ms | 5160 KB | Output is correct |
62 | Correct | 140 ms | 5136 KB | Output is correct |
63 | Incorrect | 206 ms | 4956 KB | Output isn't correct |
64 | Halted | 0 ms | 0 KB | - |