#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int N = (int)3e5 + 10;
ll A[N];
ll B[N];
ll C[N];
int main(){
fastIO;
//freopen("in.txt","r",stdin);
int n;
cin >> n;
ll m;
cin >> m;
for(int i = 1; i <= n; i ++ ){
cin >> A[i];
}
for(int i = 1; i <= n; i ++ ){
cin >> B[i];
A[i] = max(A[i], B[i]);
}
ll li = 0;
ll ri = (ll)1e16;
ll mid;
ll nd;
while(li + 1 < ri){
mid = (li + ri) / 2;
ll can;
nd = 0;
for(int i = 1; i <= n; i ++ ){
can = (mid + A[i] - 1) / A[i];
if(can <= m){
nd += m - can;
C[i] = 0;
}
else{
C[i] = mid - A[i] * 1ll * m;
}
}
for(int i = 1; i <= n; i ++ ){
nd -= (C[i] + B[i] - 1) / B[i];
if(nd < 0) break;
}
if(nd >= 0){
li = mid;
}
else{
ri = mid;
}
}
cout << li << "\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Correct |
0 ms |
332 KB |
Output is correct |
7 |
Correct |
0 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
0 ms |
332 KB |
Output is correct |
10 |
Correct |
3 ms |
332 KB |
Output is correct |
11 |
Correct |
169 ms |
7336 KB |
Output is correct |
12 |
Correct |
160 ms |
7236 KB |
Output is correct |
13 |
Correct |
160 ms |
7248 KB |
Output is correct |
14 |
Correct |
157 ms |
7256 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
169 ms |
7344 KB |
Output is correct |
17 |
Correct |
178 ms |
7216 KB |
Output is correct |
18 |
Correct |
161 ms |
7236 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
169 ms |
7344 KB |
Output is correct |
3 |
Correct |
178 ms |
7216 KB |
Output is correct |
4 |
Correct |
161 ms |
7236 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
0 ms |
332 KB |
Output is correct |
8 |
Correct |
0 ms |
332 KB |
Output is correct |
9 |
Correct |
0 ms |
332 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
332 KB |
Output is correct |
12 |
Correct |
0 ms |
332 KB |
Output is correct |
13 |
Correct |
93 ms |
3836 KB |
Output is correct |
14 |
Correct |
62 ms |
2660 KB |
Output is correct |
15 |
Correct |
45 ms |
2072 KB |
Output is correct |
16 |
Correct |
39 ms |
1612 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
0 ms |
332 KB |
Output is correct |
19 |
Correct |
0 ms |
332 KB |
Output is correct |
20 |
Correct |
0 ms |
204 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Correct |
3 ms |
332 KB |
Output is correct |
23 |
Correct |
4 ms |
464 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Correct |
0 ms |
332 KB |
Output is correct |
7 |
Correct |
0 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
0 ms |
332 KB |
Output is correct |
10 |
Correct |
3 ms |
332 KB |
Output is correct |
11 |
Correct |
169 ms |
7336 KB |
Output is correct |
12 |
Correct |
160 ms |
7236 KB |
Output is correct |
13 |
Correct |
160 ms |
7248 KB |
Output is correct |
14 |
Correct |
157 ms |
7256 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
0 ms |
332 KB |
Output is correct |
18 |
Correct |
0 ms |
332 KB |
Output is correct |
19 |
Correct |
0 ms |
332 KB |
Output is correct |
20 |
Correct |
0 ms |
204 KB |
Output is correct |
21 |
Correct |
0 ms |
332 KB |
Output is correct |
22 |
Correct |
0 ms |
332 KB |
Output is correct |
23 |
Correct |
93 ms |
3836 KB |
Output is correct |
24 |
Correct |
62 ms |
2660 KB |
Output is correct |
25 |
Correct |
45 ms |
2072 KB |
Output is correct |
26 |
Correct |
39 ms |
1612 KB |
Output is correct |
27 |
Correct |
1 ms |
332 KB |
Output is correct |
28 |
Correct |
0 ms |
332 KB |
Output is correct |
29 |
Correct |
0 ms |
332 KB |
Output is correct |
30 |
Correct |
0 ms |
204 KB |
Output is correct |
31 |
Correct |
1 ms |
332 KB |
Output is correct |
32 |
Correct |
3 ms |
332 KB |
Output is correct |
33 |
Correct |
4 ms |
464 KB |
Output is correct |
34 |
Correct |
0 ms |
204 KB |
Output is correct |
35 |
Correct |
169 ms |
7344 KB |
Output is correct |
36 |
Correct |
178 ms |
7216 KB |
Output is correct |
37 |
Correct |
161 ms |
7236 KB |
Output is correct |
38 |
Correct |
1 ms |
204 KB |
Output is correct |
39 |
Correct |
1 ms |
332 KB |
Output is correct |
40 |
Correct |
0 ms |
332 KB |
Output is correct |
41 |
Correct |
0 ms |
332 KB |
Output is correct |
42 |
Correct |
0 ms |
332 KB |
Output is correct |
43 |
Correct |
0 ms |
204 KB |
Output is correct |
44 |
Correct |
0 ms |
204 KB |
Output is correct |
45 |
Correct |
4 ms |
452 KB |
Output is correct |
46 |
Correct |
7 ms |
588 KB |
Output is correct |
47 |
Correct |
1 ms |
332 KB |
Output is correct |
48 |
Correct |
35 ms |
2160 KB |
Output is correct |
49 |
Correct |
1 ms |
316 KB |
Output is correct |
50 |
Correct |
1 ms |
204 KB |
Output is correct |
51 |
Correct |
4 ms |
460 KB |
Output is correct |
52 |
Correct |
0 ms |
316 KB |
Output is correct |
53 |
Correct |
0 ms |
332 KB |
Output is correct |
54 |
Correct |
1 ms |
332 KB |
Output is correct |
55 |
Correct |
101 ms |
5500 KB |
Output is correct |
56 |
Correct |
55 ms |
3140 KB |
Output is correct |
57 |
Correct |
54 ms |
3276 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
332 KB |
Output is correct |
8 |
Correct |
0 ms |
332 KB |
Output is correct |
9 |
Correct |
93 ms |
3836 KB |
Output is correct |
10 |
Correct |
62 ms |
2660 KB |
Output is correct |
11 |
Correct |
45 ms |
2072 KB |
Output is correct |
12 |
Correct |
39 ms |
1612 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
0 ms |
332 KB |
Output is correct |
15 |
Correct |
0 ms |
332 KB |
Output is correct |
16 |
Correct |
0 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
3 ms |
332 KB |
Output is correct |
19 |
Correct |
4 ms |
464 KB |
Output is correct |
20 |
Correct |
0 ms |
204 KB |
Output is correct |
21 |
Correct |
169 ms |
7344 KB |
Output is correct |
22 |
Correct |
178 ms |
7216 KB |
Output is correct |
23 |
Correct |
161 ms |
7236 KB |
Output is correct |
24 |
Correct |
43 ms |
1760 KB |
Output is correct |
25 |
Correct |
120 ms |
4416 KB |
Output is correct |
26 |
Correct |
22 ms |
1148 KB |
Output is correct |
27 |
Correct |
181 ms |
9120 KB |
Output is correct |
28 |
Correct |
193 ms |
11396 KB |
Output is correct |
29 |
Correct |
193 ms |
9924 KB |
Output is correct |
30 |
Correct |
214 ms |
9156 KB |
Output is correct |
31 |
Incorrect |
272 ms |
10384 KB |
Output isn't correct |
32 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Correct |
0 ms |
332 KB |
Output is correct |
7 |
Correct |
0 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
0 ms |
332 KB |
Output is correct |
10 |
Correct |
3 ms |
332 KB |
Output is correct |
11 |
Correct |
169 ms |
7336 KB |
Output is correct |
12 |
Correct |
160 ms |
7236 KB |
Output is correct |
13 |
Correct |
160 ms |
7248 KB |
Output is correct |
14 |
Correct |
157 ms |
7256 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
0 ms |
332 KB |
Output is correct |
18 |
Correct |
0 ms |
332 KB |
Output is correct |
19 |
Correct |
0 ms |
332 KB |
Output is correct |
20 |
Correct |
0 ms |
204 KB |
Output is correct |
21 |
Correct |
0 ms |
332 KB |
Output is correct |
22 |
Correct |
0 ms |
332 KB |
Output is correct |
23 |
Correct |
93 ms |
3836 KB |
Output is correct |
24 |
Correct |
62 ms |
2660 KB |
Output is correct |
25 |
Correct |
45 ms |
2072 KB |
Output is correct |
26 |
Correct |
39 ms |
1612 KB |
Output is correct |
27 |
Correct |
1 ms |
332 KB |
Output is correct |
28 |
Correct |
0 ms |
332 KB |
Output is correct |
29 |
Correct |
0 ms |
332 KB |
Output is correct |
30 |
Correct |
0 ms |
204 KB |
Output is correct |
31 |
Correct |
1 ms |
332 KB |
Output is correct |
32 |
Correct |
3 ms |
332 KB |
Output is correct |
33 |
Correct |
4 ms |
464 KB |
Output is correct |
34 |
Correct |
1 ms |
204 KB |
Output is correct |
35 |
Correct |
1 ms |
332 KB |
Output is correct |
36 |
Correct |
0 ms |
332 KB |
Output is correct |
37 |
Correct |
0 ms |
332 KB |
Output is correct |
38 |
Correct |
0 ms |
332 KB |
Output is correct |
39 |
Correct |
0 ms |
204 KB |
Output is correct |
40 |
Correct |
0 ms |
204 KB |
Output is correct |
41 |
Correct |
4 ms |
452 KB |
Output is correct |
42 |
Correct |
7 ms |
588 KB |
Output is correct |
43 |
Correct |
1 ms |
332 KB |
Output is correct |
44 |
Correct |
35 ms |
2160 KB |
Output is correct |
45 |
Correct |
1 ms |
316 KB |
Output is correct |
46 |
Correct |
1 ms |
204 KB |
Output is correct |
47 |
Correct |
4 ms |
460 KB |
Output is correct |
48 |
Correct |
0 ms |
316 KB |
Output is correct |
49 |
Correct |
0 ms |
332 KB |
Output is correct |
50 |
Correct |
1 ms |
332 KB |
Output is correct |
51 |
Correct |
101 ms |
5500 KB |
Output is correct |
52 |
Correct |
55 ms |
3140 KB |
Output is correct |
53 |
Correct |
54 ms |
3276 KB |
Output is correct |
54 |
Correct |
43 ms |
1760 KB |
Output is correct |
55 |
Correct |
120 ms |
4416 KB |
Output is correct |
56 |
Correct |
22 ms |
1148 KB |
Output is correct |
57 |
Correct |
181 ms |
9120 KB |
Output is correct |
58 |
Correct |
193 ms |
11396 KB |
Output is correct |
59 |
Correct |
193 ms |
9924 KB |
Output is correct |
60 |
Correct |
214 ms |
9156 KB |
Output is correct |
61 |
Incorrect |
272 ms |
10384 KB |
Output isn't correct |
62 |
Halted |
0 ms |
0 KB |
- |