# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
887558 | 2023-12-14T18:26:09 Z | salmon | Self Study (JOI22_ho_t2) | C++14 | 286 ms | 11092 KB |
#include <bits/stdc++.h> using namespace std; int N; long long int M; long long int A[300100]; long long int B[300100]; const long long int inf = 1.5e18; int main(){ scanf(" %d",&N); scanf(" %lld",&M); for(int i = 0; i < N; i++){ scanf(" %lld",&A[i]); } for(int i = 0; i < N; i++){ scanf(" %lld",&B[i]); } long long int s = 0; long long int e = inf; while(s != e){ long long int m = (s + e + 1)/2; long long int free = 0; for(int i = 0; i < N; i++){ if(B[i] > A[i]){ free += M; free -= (m + B[i] - 1) / B[i]; } else{ if( (m + A[i] - 1)/A[i] >= M){ long long int v = max(0LL,m - A[i] * M); free -= (v + B[i] - 1)/ B[i]; } else{ free += M; free -= (m + A[i] - 1)/A[i]; } } if(free < (-M * N) ){ break; } } if(free >= 0){ s = m; } else{ e = m - 1; } } printf("%lld",s); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 1 ms | 2396 KB | Output is correct |
4 | Correct | 1 ms | 2396 KB | Output is correct |
5 | Correct | 1 ms | 2396 KB | Output is correct |
6 | Correct | 1 ms | 2488 KB | Output is correct |
7 | Correct | 1 ms | 2396 KB | Output is correct |
8 | Correct | 1 ms | 2396 KB | Output is correct |
9 | Correct | 1 ms | 2396 KB | Output is correct |
10 | Correct | 2 ms | 2396 KB | Output is correct |
11 | Correct | 118 ms | 10584 KB | Output is correct |
12 | Correct | 120 ms | 10404 KB | Output is correct |
13 | Correct | 94 ms | 8676 KB | Output is correct |
14 | Correct | 99 ms | 8688 KB | Output is correct |
15 | Correct | 1 ms | 2396 KB | Output is correct |
16 | Correct | 49 ms | 5880 KB | Output is correct |
17 | Correct | 151 ms | 8696 KB | Output is correct |
18 | Correct | 129 ms | 8040 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Correct | 49 ms | 5880 KB | Output is correct |
3 | Correct | 151 ms | 8696 KB | Output is correct |
4 | Correct | 129 ms | 8040 KB | Output is correct |
5 | Correct | 1 ms | 2652 KB | Output is correct |
6 | Correct | 1 ms | 2488 KB | Output is correct |
7 | Correct | 1 ms | 2396 KB | Output is correct |
8 | Correct | 1 ms | 2396 KB | Output is correct |
9 | Correct | 1 ms | 2392 KB | Output is correct |
10 | Correct | 1 ms | 2396 KB | Output is correct |
11 | Correct | 1 ms | 2396 KB | Output is correct |
12 | Correct | 1 ms | 2396 KB | Output is correct |
13 | Correct | 52 ms | 6572 KB | Output is correct |
14 | Correct | 34 ms | 5724 KB | Output is correct |
15 | Correct | 25 ms | 5724 KB | Output is correct |
16 | Correct | 23 ms | 5412 KB | Output is correct |
17 | Correct | 1 ms | 2396 KB | Output is correct |
18 | Correct | 1 ms | 2488 KB | Output is correct |
19 | Correct | 1 ms | 2396 KB | Output is correct |
20 | Correct | 1 ms | 2396 KB | Output is correct |
21 | Correct | 1 ms | 2500 KB | Output is correct |
22 | Correct | 2 ms | 2396 KB | Output is correct |
23 | Correct | 3 ms | 2396 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 1 ms | 2396 KB | Output is correct |
4 | Correct | 1 ms | 2396 KB | Output is correct |
5 | Correct | 1 ms | 2396 KB | Output is correct |
6 | Correct | 1 ms | 2488 KB | Output is correct |
7 | Correct | 1 ms | 2396 KB | Output is correct |
8 | Correct | 1 ms | 2396 KB | Output is correct |
9 | Correct | 1 ms | 2396 KB | Output is correct |
10 | Correct | 2 ms | 2396 KB | Output is correct |
11 | Correct | 118 ms | 10584 KB | Output is correct |
12 | Correct | 120 ms | 10404 KB | Output is correct |
13 | Correct | 94 ms | 8676 KB | Output is correct |
14 | Correct | 99 ms | 8688 KB | Output is correct |
15 | Correct | 1 ms | 2652 KB | Output is correct |
16 | Correct | 1 ms | 2488 KB | Output is correct |
17 | Correct | 1 ms | 2396 KB | Output is correct |
18 | Correct | 1 ms | 2396 KB | Output is correct |
19 | Correct | 1 ms | 2392 KB | Output is correct |
20 | Correct | 1 ms | 2396 KB | Output is correct |
21 | Correct | 1 ms | 2396 KB | Output is correct |
22 | Correct | 1 ms | 2396 KB | Output is correct |
23 | Correct | 52 ms | 6572 KB | Output is correct |
24 | Correct | 34 ms | 5724 KB | Output is correct |
25 | Correct | 25 ms | 5724 KB | Output is correct |
26 | Correct | 23 ms | 5412 KB | Output is correct |
27 | Correct | 1 ms | 2396 KB | Output is correct |
28 | Correct | 1 ms | 2488 KB | Output is correct |
29 | Correct | 1 ms | 2396 KB | Output is correct |
30 | Correct | 1 ms | 2396 KB | Output is correct |
31 | Correct | 1 ms | 2500 KB | Output is correct |
32 | Correct | 2 ms | 2396 KB | Output is correct |
33 | Correct | 3 ms | 2396 KB | Output is correct |
34 | Correct | 1 ms | 2396 KB | Output is correct |
35 | Correct | 49 ms | 5880 KB | Output is correct |
36 | Correct | 151 ms | 8696 KB | Output is correct |
37 | Correct | 129 ms | 8040 KB | Output is correct |
38 | Correct | 1 ms | 2396 KB | Output is correct |
39 | Correct | 1 ms | 2396 KB | Output is correct |
40 | Correct | 1 ms | 2396 KB | Output is correct |
41 | Correct | 1 ms | 2396 KB | Output is correct |
42 | Correct | 1 ms | 2396 KB | Output is correct |
43 | Correct | 1 ms | 2396 KB | Output is correct |
44 | Correct | 1 ms | 2396 KB | Output is correct |
45 | Correct | 3 ms | 2396 KB | Output is correct |
46 | Correct | 4 ms | 2652 KB | Output is correct |
47 | Correct | 1 ms | 2504 KB | Output is correct |
48 | Correct | 22 ms | 5724 KB | Output is correct |
49 | Correct | 1 ms | 2396 KB | Output is correct |
50 | Correct | 1 ms | 2396 KB | Output is correct |
51 | Correct | 2 ms | 2584 KB | Output is correct |
52 | Correct | 0 ms | 2392 KB | Output is correct |
53 | Correct | 1 ms | 2396 KB | Output is correct |
54 | Correct | 1 ms | 2396 KB | Output is correct |
55 | Correct | 59 ms | 7516 KB | Output is correct |
56 | Correct | 33 ms | 5980 KB | Output is correct |
57 | Correct | 32 ms | 5980 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2652 KB | Output is correct |
2 | Correct | 1 ms | 2488 KB | Output is correct |
3 | Correct | 1 ms | 2396 KB | Output is correct |
4 | Correct | 1 ms | 2396 KB | Output is correct |
5 | Correct | 1 ms | 2392 KB | Output is correct |
6 | Correct | 1 ms | 2396 KB | Output is correct |
7 | Correct | 1 ms | 2396 KB | Output is correct |
8 | Correct | 1 ms | 2396 KB | Output is correct |
9 | Correct | 52 ms | 6572 KB | Output is correct |
10 | Correct | 34 ms | 5724 KB | Output is correct |
11 | Correct | 25 ms | 5724 KB | Output is correct |
12 | Correct | 23 ms | 5412 KB | Output is correct |
13 | Correct | 1 ms | 2396 KB | Output is correct |
14 | Correct | 1 ms | 2488 KB | Output is correct |
15 | Correct | 1 ms | 2396 KB | Output is correct |
16 | Correct | 1 ms | 2396 KB | Output is correct |
17 | Correct | 1 ms | 2500 KB | Output is correct |
18 | Correct | 2 ms | 2396 KB | Output is correct |
19 | Correct | 3 ms | 2396 KB | Output is correct |
20 | Correct | 1 ms | 2396 KB | Output is correct |
21 | Correct | 49 ms | 5880 KB | Output is correct |
22 | Correct | 151 ms | 8696 KB | Output is correct |
23 | Correct | 129 ms | 8040 KB | Output is correct |
24 | Correct | 31 ms | 5464 KB | Output is correct |
25 | Correct | 75 ms | 6176 KB | Output is correct |
26 | Correct | 14 ms | 5212 KB | Output is correct |
27 | Correct | 93 ms | 7956 KB | Output is correct |
28 | Correct | 107 ms | 8176 KB | Output is correct |
29 | Correct | 107 ms | 8020 KB | Output is correct |
30 | Correct | 131 ms | 8016 KB | Output is correct |
31 | Correct | 203 ms | 8016 KB | Output is correct |
32 | Correct | 168 ms | 5720 KB | Output is correct |
33 | Correct | 286 ms | 8692 KB | Output is correct |
34 | Correct | 171 ms | 5888 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 1 ms | 2396 KB | Output is correct |
4 | Correct | 1 ms | 2396 KB | Output is correct |
5 | Correct | 1 ms | 2396 KB | Output is correct |
6 | Correct | 1 ms | 2488 KB | Output is correct |
7 | Correct | 1 ms | 2396 KB | Output is correct |
8 | Correct | 1 ms | 2396 KB | Output is correct |
9 | Correct | 1 ms | 2396 KB | Output is correct |
10 | Correct | 2 ms | 2396 KB | Output is correct |
11 | Correct | 118 ms | 10584 KB | Output is correct |
12 | Correct | 120 ms | 10404 KB | Output is correct |
13 | Correct | 94 ms | 8676 KB | Output is correct |
14 | Correct | 99 ms | 8688 KB | Output is correct |
15 | Correct | 1 ms | 2652 KB | Output is correct |
16 | Correct | 1 ms | 2488 KB | Output is correct |
17 | Correct | 1 ms | 2396 KB | Output is correct |
18 | Correct | 1 ms | 2396 KB | Output is correct |
19 | Correct | 1 ms | 2392 KB | Output is correct |
20 | Correct | 1 ms | 2396 KB | Output is correct |
21 | Correct | 1 ms | 2396 KB | Output is correct |
22 | Correct | 1 ms | 2396 KB | Output is correct |
23 | Correct | 52 ms | 6572 KB | Output is correct |
24 | Correct | 34 ms | 5724 KB | Output is correct |
25 | Correct | 25 ms | 5724 KB | Output is correct |
26 | Correct | 23 ms | 5412 KB | Output is correct |
27 | Correct | 1 ms | 2396 KB | Output is correct |
28 | Correct | 1 ms | 2488 KB | Output is correct |
29 | Correct | 1 ms | 2396 KB | Output is correct |
30 | Correct | 1 ms | 2396 KB | Output is correct |
31 | Correct | 1 ms | 2500 KB | Output is correct |
32 | Correct | 2 ms | 2396 KB | Output is correct |
33 | Correct | 3 ms | 2396 KB | Output is correct |
34 | Correct | 1 ms | 2396 KB | Output is correct |
35 | Correct | 1 ms | 2396 KB | Output is correct |
36 | Correct | 1 ms | 2396 KB | Output is correct |
37 | Correct | 1 ms | 2396 KB | Output is correct |
38 | Correct | 1 ms | 2396 KB | Output is correct |
39 | Correct | 1 ms | 2396 KB | Output is correct |
40 | Correct | 1 ms | 2396 KB | Output is correct |
41 | Correct | 3 ms | 2396 KB | Output is correct |
42 | Correct | 4 ms | 2652 KB | Output is correct |
43 | Correct | 1 ms | 2504 KB | Output is correct |
44 | Correct | 22 ms | 5724 KB | Output is correct |
45 | Correct | 1 ms | 2396 KB | Output is correct |
46 | Correct | 1 ms | 2396 KB | Output is correct |
47 | Correct | 2 ms | 2584 KB | Output is correct |
48 | Correct | 0 ms | 2392 KB | Output is correct |
49 | Correct | 1 ms | 2396 KB | Output is correct |
50 | Correct | 1 ms | 2396 KB | Output is correct |
51 | Correct | 59 ms | 7516 KB | Output is correct |
52 | Correct | 33 ms | 5980 KB | Output is correct |
53 | Correct | 32 ms | 5980 KB | Output is correct |
54 | Correct | 31 ms | 5464 KB | Output is correct |
55 | Correct | 75 ms | 6176 KB | Output is correct |
56 | Correct | 14 ms | 5212 KB | Output is correct |
57 | Correct | 93 ms | 7956 KB | Output is correct |
58 | Correct | 107 ms | 8176 KB | Output is correct |
59 | Correct | 107 ms | 8020 KB | Output is correct |
60 | Correct | 131 ms | 8016 KB | Output is correct |
61 | Correct | 203 ms | 8016 KB | Output is correct |
62 | Correct | 168 ms | 5720 KB | Output is correct |
63 | Correct | 286 ms | 8692 KB | Output is correct |
64 | Correct | 171 ms | 5888 KB | Output is correct |
65 | Correct | 1 ms | 2396 KB | Output is correct |
66 | Correct | 49 ms | 5880 KB | Output is correct |
67 | Correct | 151 ms | 8696 KB | Output is correct |
68 | Correct | 129 ms | 8040 KB | Output is correct |
69 | Correct | 21 ms | 5132 KB | Output is correct |
70 | Correct | 6 ms | 2600 KB | Output is correct |
71 | Correct | 1 ms | 2396 KB | Output is correct |
72 | Correct | 32 ms | 5456 KB | Output is correct |
73 | Correct | 7 ms | 2652 KB | Output is correct |
74 | Correct | 1 ms | 2396 KB | Output is correct |
75 | Correct | 123 ms | 10896 KB | Output is correct |
76 | Correct | 123 ms | 11092 KB | Output is correct |
77 | Correct | 131 ms | 10852 KB | Output is correct |
78 | Correct | 159 ms | 10904 KB | Output is correct |
79 | Correct | 209 ms | 10916 KB | Output is correct |
80 | Correct | 218 ms | 10784 KB | Output is correct |
81 | Correct | 208 ms | 8920 KB | Output is correct |
82 | Correct | 225 ms | 8920 KB | Output is correct |