#include<bits/stdc++.h>
#define forn(i,n) for(int i = 0;i < (n);i++)
#define Forn(i,n) for(int i = 1;i <= (n);i++)
#define all(p) p.begin(),p.end()
#define pb push_back
#define F first
#define S second
#define rz resize
#define sz(x) x.size()
#define int long long
#define vi vector<int>
#define pii pair<int,int>
using namespace std;
const int INF = 5000009;
int n,m;
void solve(){
cin >> n >> m;
vi a(n),b(n);
forn(i,n) cin >> a[i];
forn(i,n) cin >> b[i];
forn(i,n){
if(b[i] > a[i]) a[i] = max(b[i],a[i]);
}
int lo = 0,hi = 2e18;
while(lo != hi-1){
int mid = (lo+hi)/2;
int res = 0;
forn(i,n){
if(a[i] * m < mid){
res -= ceil(((double)mid - a[i] * m) / b[i]);
continue;
}
int c = ceil((double)mid/a[i]);
res += (m-c);
}
if(res >= 0) lo = mid;
else hi = mid;
}
cout << lo << '\n';
}
signed main(){
cin.tie(NULL);
cout.tie(NULL);
ios_base::sync_with_stdio(0);
solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
3 ms |
460 KB |
Output is correct |
11 |
Correct |
148 ms |
10112 KB |
Output is correct |
12 |
Correct |
148 ms |
10164 KB |
Output is correct |
13 |
Correct |
163 ms |
8240 KB |
Output is correct |
14 |
Correct |
168 ms |
7984 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
139 ms |
6136 KB |
Output is correct |
17 |
Correct |
175 ms |
10172 KB |
Output is correct |
18 |
Correct |
145 ms |
9304 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
139 ms |
6136 KB |
Output is correct |
3 |
Correct |
175 ms |
10172 KB |
Output is correct |
4 |
Correct |
145 ms |
9304 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
312 KB |
Output is correct |
10 |
Correct |
1 ms |
292 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
71 ms |
5408 KB |
Output is correct |
14 |
Correct |
48 ms |
3800 KB |
Output is correct |
15 |
Correct |
39 ms |
2984 KB |
Output is correct |
16 |
Correct |
40 ms |
2384 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
3 ms |
332 KB |
Output is correct |
23 |
Correct |
3 ms |
472 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
3 ms |
460 KB |
Output is correct |
11 |
Correct |
148 ms |
10112 KB |
Output is correct |
12 |
Correct |
148 ms |
10164 KB |
Output is correct |
13 |
Correct |
163 ms |
8240 KB |
Output is correct |
14 |
Correct |
168 ms |
7984 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
312 KB |
Output is correct |
20 |
Correct |
1 ms |
292 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
71 ms |
5408 KB |
Output is correct |
24 |
Correct |
48 ms |
3800 KB |
Output is correct |
25 |
Correct |
39 ms |
2984 KB |
Output is correct |
26 |
Correct |
40 ms |
2384 KB |
Output is correct |
27 |
Correct |
1 ms |
204 KB |
Output is correct |
28 |
Correct |
1 ms |
204 KB |
Output is correct |
29 |
Correct |
1 ms |
204 KB |
Output is correct |
30 |
Correct |
1 ms |
204 KB |
Output is correct |
31 |
Correct |
1 ms |
204 KB |
Output is correct |
32 |
Correct |
3 ms |
332 KB |
Output is correct |
33 |
Correct |
3 ms |
472 KB |
Output is correct |
34 |
Correct |
1 ms |
204 KB |
Output is correct |
35 |
Correct |
139 ms |
6136 KB |
Output is correct |
36 |
Correct |
175 ms |
10172 KB |
Output is correct |
37 |
Correct |
145 ms |
9304 KB |
Output is correct |
38 |
Correct |
1 ms |
204 KB |
Output is correct |
39 |
Correct |
1 ms |
308 KB |
Output is correct |
40 |
Correct |
1 ms |
204 KB |
Output is correct |
41 |
Correct |
1 ms |
204 KB |
Output is correct |
42 |
Correct |
1 ms |
204 KB |
Output is correct |
43 |
Correct |
1 ms |
204 KB |
Output is correct |
44 |
Correct |
1 ms |
204 KB |
Output is correct |
45 |
Correct |
3 ms |
460 KB |
Output is correct |
46 |
Correct |
5 ms |
588 KB |
Output is correct |
47 |
Correct |
1 ms |
332 KB |
Output is correct |
48 |
Correct |
26 ms |
1988 KB |
Output is correct |
49 |
Correct |
1 ms |
204 KB |
Output is correct |
50 |
Correct |
1 ms |
204 KB |
Output is correct |
51 |
Correct |
3 ms |
460 KB |
Output is correct |
52 |
Correct |
1 ms |
204 KB |
Output is correct |
53 |
Correct |
1 ms |
204 KB |
Output is correct |
54 |
Correct |
1 ms |
204 KB |
Output is correct |
55 |
Correct |
84 ms |
4120 KB |
Output is correct |
56 |
Correct |
53 ms |
3128 KB |
Output is correct |
57 |
Correct |
51 ms |
3140 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
312 KB |
Output is correct |
6 |
Correct |
1 ms |
292 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
71 ms |
5408 KB |
Output is correct |
10 |
Correct |
48 ms |
3800 KB |
Output is correct |
11 |
Correct |
39 ms |
2984 KB |
Output is correct |
12 |
Correct |
40 ms |
2384 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
3 ms |
332 KB |
Output is correct |
19 |
Correct |
3 ms |
472 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
139 ms |
6136 KB |
Output is correct |
22 |
Correct |
175 ms |
10172 KB |
Output is correct |
23 |
Correct |
145 ms |
9304 KB |
Output is correct |
24 |
Correct |
22 ms |
1856 KB |
Output is correct |
25 |
Correct |
68 ms |
3656 KB |
Output is correct |
26 |
Correct |
16 ms |
1316 KB |
Output is correct |
27 |
Correct |
143 ms |
6348 KB |
Output is correct |
28 |
Correct |
154 ms |
6352 KB |
Output is correct |
29 |
Correct |
154 ms |
6356 KB |
Output is correct |
30 |
Correct |
145 ms |
6252 KB |
Output is correct |
31 |
Incorrect |
137 ms |
6664 KB |
Output isn't correct |
32 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
3 ms |
460 KB |
Output is correct |
11 |
Correct |
148 ms |
10112 KB |
Output is correct |
12 |
Correct |
148 ms |
10164 KB |
Output is correct |
13 |
Correct |
163 ms |
8240 KB |
Output is correct |
14 |
Correct |
168 ms |
7984 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
312 KB |
Output is correct |
20 |
Correct |
1 ms |
292 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
71 ms |
5408 KB |
Output is correct |
24 |
Correct |
48 ms |
3800 KB |
Output is correct |
25 |
Correct |
39 ms |
2984 KB |
Output is correct |
26 |
Correct |
40 ms |
2384 KB |
Output is correct |
27 |
Correct |
1 ms |
204 KB |
Output is correct |
28 |
Correct |
1 ms |
204 KB |
Output is correct |
29 |
Correct |
1 ms |
204 KB |
Output is correct |
30 |
Correct |
1 ms |
204 KB |
Output is correct |
31 |
Correct |
1 ms |
204 KB |
Output is correct |
32 |
Correct |
3 ms |
332 KB |
Output is correct |
33 |
Correct |
3 ms |
472 KB |
Output is correct |
34 |
Correct |
1 ms |
204 KB |
Output is correct |
35 |
Correct |
1 ms |
308 KB |
Output is correct |
36 |
Correct |
1 ms |
204 KB |
Output is correct |
37 |
Correct |
1 ms |
204 KB |
Output is correct |
38 |
Correct |
1 ms |
204 KB |
Output is correct |
39 |
Correct |
1 ms |
204 KB |
Output is correct |
40 |
Correct |
1 ms |
204 KB |
Output is correct |
41 |
Correct |
3 ms |
460 KB |
Output is correct |
42 |
Correct |
5 ms |
588 KB |
Output is correct |
43 |
Correct |
1 ms |
332 KB |
Output is correct |
44 |
Correct |
26 ms |
1988 KB |
Output is correct |
45 |
Correct |
1 ms |
204 KB |
Output is correct |
46 |
Correct |
1 ms |
204 KB |
Output is correct |
47 |
Correct |
3 ms |
460 KB |
Output is correct |
48 |
Correct |
1 ms |
204 KB |
Output is correct |
49 |
Correct |
1 ms |
204 KB |
Output is correct |
50 |
Correct |
1 ms |
204 KB |
Output is correct |
51 |
Correct |
84 ms |
4120 KB |
Output is correct |
52 |
Correct |
53 ms |
3128 KB |
Output is correct |
53 |
Correct |
51 ms |
3140 KB |
Output is correct |
54 |
Correct |
22 ms |
1856 KB |
Output is correct |
55 |
Correct |
68 ms |
3656 KB |
Output is correct |
56 |
Correct |
16 ms |
1316 KB |
Output is correct |
57 |
Correct |
143 ms |
6348 KB |
Output is correct |
58 |
Correct |
154 ms |
6352 KB |
Output is correct |
59 |
Correct |
154 ms |
6356 KB |
Output is correct |
60 |
Correct |
145 ms |
6252 KB |
Output is correct |
61 |
Incorrect |
137 ms |
6664 KB |
Output isn't correct |
62 |
Halted |
0 ms |
0 KB |
- |