/*
IN THE NAME OF GOD
*/
#include <bits/stdc++.h>
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
using namespace std;
typedef __int128 ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef long double ld;
#define F first
#define S second
#define Mp make_pair
#define pb push_back
#define pf push_front
#define size(x) ((ll)x.size())
#define all(x) (x).begin(),(x).end()
#define kill(x) cout << x << '\n', exit(0);
#define fuck(x) cout << "(" << #x << " , " << x << ")" << endl
#define endl '\n'
const int N = 3e5+23, lg = 18;
ll Mod = 1e9+7; //998244353;
inline ll MOD(ll a, ll mod=Mod) {a%=mod; (a<0)&&(a+=mod); return a;}
inline ll poww(ll a, ll b, ll mod=Mod) {
ll ans = 1;
a=MOD(a, mod);
while (b) {
if (b & 1) ans = MOD(ans*a, mod);
b >>= 1;
a = MOD(a*a, mod);
}
return ans;
}
int64_t nn, mm, A[N], B[N];
int64_t n, m, a[N], b[N];
int main () {
ios_base::sync_with_stdio(false), cin.tie(0);
cin>>nn>>mm;
for(int i=1; i<=nn; i++) cin>>A[i];
for(int i=1; i<=nn; i++) cin>>B[i];
n=nn, m=mm;
for(int i=1; i<=n; i++) a[i]=A[i], b[i]=B[i];
int64_t l=0, r=1e18+1;
while(r-l > 1) {
int64_t mid = (l+r)/2;
ll nump = 0, numn = 0;
for(int i=1; i<=n; i++) {
if(a[i] >= b[i]) {
numn += max(int64_t(0), m - ((mid+a[i]-1)/a[i]));
nump += max(int64_t(0), ((mid-m*a[i]+b[i]-1)/b[i]));
} else {
numn += max(int64_t(0), m - ((mid+b[i]-1)/b[i]));
nump += max(int64_t(0), ((mid-m*b[i]+b[i]-1)/b[i]));
}
}
(numn>=nump ? l=mid : r=mid);
}
cout<<l<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6744 KB |
Output is correct |
2 |
Correct |
2 ms |
6488 KB |
Output is correct |
3 |
Correct |
1 ms |
6488 KB |
Output is correct |
4 |
Correct |
1 ms |
6488 KB |
Output is correct |
5 |
Correct |
1 ms |
6488 KB |
Output is correct |
6 |
Correct |
2 ms |
6488 KB |
Output is correct |
7 |
Correct |
1 ms |
6488 KB |
Output is correct |
8 |
Correct |
1 ms |
6488 KB |
Output is correct |
9 |
Correct |
1 ms |
6492 KB |
Output is correct |
10 |
Correct |
5 ms |
6488 KB |
Output is correct |
11 |
Correct |
248 ms |
9808 KB |
Output is correct |
12 |
Correct |
243 ms |
9896 KB |
Output is correct |
13 |
Correct |
230 ms |
9808 KB |
Output is correct |
14 |
Correct |
288 ms |
9832 KB |
Output is correct |
15 |
Correct |
2 ms |
6688 KB |
Output is correct |
16 |
Correct |
333 ms |
9832 KB |
Output is correct |
17 |
Correct |
240 ms |
9828 KB |
Output is correct |
18 |
Correct |
247 ms |
9996 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
6688 KB |
Output is correct |
2 |
Correct |
333 ms |
9832 KB |
Output is correct |
3 |
Correct |
240 ms |
9828 KB |
Output is correct |
4 |
Correct |
247 ms |
9996 KB |
Output is correct |
5 |
Correct |
1 ms |
6488 KB |
Output is correct |
6 |
Correct |
1 ms |
6488 KB |
Output is correct |
7 |
Correct |
2 ms |
6488 KB |
Output is correct |
8 |
Correct |
1 ms |
6488 KB |
Output is correct |
9 |
Correct |
1 ms |
6488 KB |
Output is correct |
10 |
Correct |
2 ms |
6488 KB |
Output is correct |
11 |
Correct |
2 ms |
6488 KB |
Output is correct |
12 |
Correct |
1 ms |
6488 KB |
Output is correct |
13 |
Correct |
121 ms |
8824 KB |
Output is correct |
14 |
Correct |
83 ms |
8792 KB |
Output is correct |
15 |
Correct |
63 ms |
8792 KB |
Output is correct |
16 |
Correct |
50 ms |
8828 KB |
Output is correct |
17 |
Correct |
2 ms |
6488 KB |
Output is correct |
18 |
Correct |
1 ms |
6488 KB |
Output is correct |
19 |
Correct |
1 ms |
6488 KB |
Output is correct |
20 |
Correct |
1 ms |
6488 KB |
Output is correct |
21 |
Correct |
1 ms |
6488 KB |
Output is correct |
22 |
Correct |
7 ms |
6488 KB |
Output is correct |
23 |
Correct |
5 ms |
6488 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6744 KB |
Output is correct |
2 |
Correct |
2 ms |
6488 KB |
Output is correct |
3 |
Correct |
1 ms |
6488 KB |
Output is correct |
4 |
Correct |
1 ms |
6488 KB |
Output is correct |
5 |
Correct |
1 ms |
6488 KB |
Output is correct |
6 |
Correct |
2 ms |
6488 KB |
Output is correct |
7 |
Correct |
1 ms |
6488 KB |
Output is correct |
8 |
Correct |
1 ms |
6488 KB |
Output is correct |
9 |
Correct |
1 ms |
6492 KB |
Output is correct |
10 |
Correct |
5 ms |
6488 KB |
Output is correct |
11 |
Correct |
248 ms |
9808 KB |
Output is correct |
12 |
Correct |
243 ms |
9896 KB |
Output is correct |
13 |
Correct |
230 ms |
9808 KB |
Output is correct |
14 |
Correct |
288 ms |
9832 KB |
Output is correct |
15 |
Correct |
1 ms |
6488 KB |
Output is correct |
16 |
Correct |
1 ms |
6488 KB |
Output is correct |
17 |
Correct |
2 ms |
6488 KB |
Output is correct |
18 |
Correct |
1 ms |
6488 KB |
Output is correct |
19 |
Correct |
1 ms |
6488 KB |
Output is correct |
20 |
Correct |
2 ms |
6488 KB |
Output is correct |
21 |
Correct |
2 ms |
6488 KB |
Output is correct |
22 |
Correct |
1 ms |
6488 KB |
Output is correct |
23 |
Correct |
121 ms |
8824 KB |
Output is correct |
24 |
Correct |
83 ms |
8792 KB |
Output is correct |
25 |
Correct |
63 ms |
8792 KB |
Output is correct |
26 |
Correct |
50 ms |
8828 KB |
Output is correct |
27 |
Correct |
2 ms |
6488 KB |
Output is correct |
28 |
Correct |
1 ms |
6488 KB |
Output is correct |
29 |
Correct |
1 ms |
6488 KB |
Output is correct |
30 |
Correct |
1 ms |
6488 KB |
Output is correct |
31 |
Correct |
1 ms |
6488 KB |
Output is correct |
32 |
Correct |
7 ms |
6488 KB |
Output is correct |
33 |
Correct |
5 ms |
6488 KB |
Output is correct |
34 |
Correct |
2 ms |
6688 KB |
Output is correct |
35 |
Correct |
333 ms |
9832 KB |
Output is correct |
36 |
Correct |
240 ms |
9828 KB |
Output is correct |
37 |
Correct |
247 ms |
9996 KB |
Output is correct |
38 |
Correct |
1 ms |
6488 KB |
Output is correct |
39 |
Correct |
2 ms |
6488 KB |
Output is correct |
40 |
Correct |
2 ms |
6488 KB |
Output is correct |
41 |
Correct |
2 ms |
6744 KB |
Output is correct |
42 |
Correct |
1 ms |
6488 KB |
Output is correct |
43 |
Correct |
1 ms |
6488 KB |
Output is correct |
44 |
Correct |
1 ms |
6488 KB |
Output is correct |
45 |
Correct |
5 ms |
6488 KB |
Output is correct |
46 |
Correct |
8 ms |
6688 KB |
Output is correct |
47 |
Correct |
2 ms |
6488 KB |
Output is correct |
48 |
Correct |
42 ms |
8792 KB |
Output is correct |
49 |
Correct |
1 ms |
6488 KB |
Output is correct |
50 |
Correct |
1 ms |
6488 KB |
Output is correct |
51 |
Correct |
6 ms |
6488 KB |
Output is correct |
52 |
Correct |
1 ms |
6488 KB |
Output is correct |
53 |
Correct |
1 ms |
6488 KB |
Output is correct |
54 |
Correct |
1 ms |
6488 KB |
Output is correct |
55 |
Correct |
121 ms |
8792 KB |
Output is correct |
56 |
Correct |
79 ms |
8832 KB |
Output is correct |
57 |
Correct |
98 ms |
8792 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6488 KB |
Output is correct |
2 |
Correct |
1 ms |
6488 KB |
Output is correct |
3 |
Correct |
2 ms |
6488 KB |
Output is correct |
4 |
Correct |
1 ms |
6488 KB |
Output is correct |
5 |
Correct |
1 ms |
6488 KB |
Output is correct |
6 |
Correct |
2 ms |
6488 KB |
Output is correct |
7 |
Correct |
2 ms |
6488 KB |
Output is correct |
8 |
Correct |
1 ms |
6488 KB |
Output is correct |
9 |
Correct |
121 ms |
8824 KB |
Output is correct |
10 |
Correct |
83 ms |
8792 KB |
Output is correct |
11 |
Correct |
63 ms |
8792 KB |
Output is correct |
12 |
Correct |
50 ms |
8828 KB |
Output is correct |
13 |
Correct |
2 ms |
6488 KB |
Output is correct |
14 |
Correct |
1 ms |
6488 KB |
Output is correct |
15 |
Correct |
1 ms |
6488 KB |
Output is correct |
16 |
Correct |
1 ms |
6488 KB |
Output is correct |
17 |
Correct |
1 ms |
6488 KB |
Output is correct |
18 |
Correct |
7 ms |
6488 KB |
Output is correct |
19 |
Correct |
5 ms |
6488 KB |
Output is correct |
20 |
Correct |
2 ms |
6688 KB |
Output is correct |
21 |
Correct |
333 ms |
9832 KB |
Output is correct |
22 |
Correct |
240 ms |
9828 KB |
Output is correct |
23 |
Correct |
247 ms |
9996 KB |
Output is correct |
24 |
Correct |
52 ms |
8792 KB |
Output is correct |
25 |
Correct |
132 ms |
8824 KB |
Output is correct |
26 |
Correct |
29 ms |
8792 KB |
Output is correct |
27 |
Correct |
247 ms |
9672 KB |
Output is correct |
28 |
Correct |
243 ms |
9808 KB |
Output is correct |
29 |
Correct |
251 ms |
9636 KB |
Output is correct |
30 |
Correct |
266 ms |
10064 KB |
Output is correct |
31 |
Correct |
353 ms |
9640 KB |
Output is correct |
32 |
Correct |
353 ms |
9808 KB |
Output is correct |
33 |
Incorrect |
304 ms |
10064 KB |
Output isn't correct |
34 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6744 KB |
Output is correct |
2 |
Correct |
2 ms |
6488 KB |
Output is correct |
3 |
Correct |
1 ms |
6488 KB |
Output is correct |
4 |
Correct |
1 ms |
6488 KB |
Output is correct |
5 |
Correct |
1 ms |
6488 KB |
Output is correct |
6 |
Correct |
2 ms |
6488 KB |
Output is correct |
7 |
Correct |
1 ms |
6488 KB |
Output is correct |
8 |
Correct |
1 ms |
6488 KB |
Output is correct |
9 |
Correct |
1 ms |
6492 KB |
Output is correct |
10 |
Correct |
5 ms |
6488 KB |
Output is correct |
11 |
Correct |
248 ms |
9808 KB |
Output is correct |
12 |
Correct |
243 ms |
9896 KB |
Output is correct |
13 |
Correct |
230 ms |
9808 KB |
Output is correct |
14 |
Correct |
288 ms |
9832 KB |
Output is correct |
15 |
Correct |
1 ms |
6488 KB |
Output is correct |
16 |
Correct |
1 ms |
6488 KB |
Output is correct |
17 |
Correct |
2 ms |
6488 KB |
Output is correct |
18 |
Correct |
1 ms |
6488 KB |
Output is correct |
19 |
Correct |
1 ms |
6488 KB |
Output is correct |
20 |
Correct |
2 ms |
6488 KB |
Output is correct |
21 |
Correct |
2 ms |
6488 KB |
Output is correct |
22 |
Correct |
1 ms |
6488 KB |
Output is correct |
23 |
Correct |
121 ms |
8824 KB |
Output is correct |
24 |
Correct |
83 ms |
8792 KB |
Output is correct |
25 |
Correct |
63 ms |
8792 KB |
Output is correct |
26 |
Correct |
50 ms |
8828 KB |
Output is correct |
27 |
Correct |
2 ms |
6488 KB |
Output is correct |
28 |
Correct |
1 ms |
6488 KB |
Output is correct |
29 |
Correct |
1 ms |
6488 KB |
Output is correct |
30 |
Correct |
1 ms |
6488 KB |
Output is correct |
31 |
Correct |
1 ms |
6488 KB |
Output is correct |
32 |
Correct |
7 ms |
6488 KB |
Output is correct |
33 |
Correct |
5 ms |
6488 KB |
Output is correct |
34 |
Correct |
1 ms |
6488 KB |
Output is correct |
35 |
Correct |
2 ms |
6488 KB |
Output is correct |
36 |
Correct |
2 ms |
6488 KB |
Output is correct |
37 |
Correct |
2 ms |
6744 KB |
Output is correct |
38 |
Correct |
1 ms |
6488 KB |
Output is correct |
39 |
Correct |
1 ms |
6488 KB |
Output is correct |
40 |
Correct |
1 ms |
6488 KB |
Output is correct |
41 |
Correct |
5 ms |
6488 KB |
Output is correct |
42 |
Correct |
8 ms |
6688 KB |
Output is correct |
43 |
Correct |
2 ms |
6488 KB |
Output is correct |
44 |
Correct |
42 ms |
8792 KB |
Output is correct |
45 |
Correct |
1 ms |
6488 KB |
Output is correct |
46 |
Correct |
1 ms |
6488 KB |
Output is correct |
47 |
Correct |
6 ms |
6488 KB |
Output is correct |
48 |
Correct |
1 ms |
6488 KB |
Output is correct |
49 |
Correct |
1 ms |
6488 KB |
Output is correct |
50 |
Correct |
1 ms |
6488 KB |
Output is correct |
51 |
Correct |
121 ms |
8792 KB |
Output is correct |
52 |
Correct |
79 ms |
8832 KB |
Output is correct |
53 |
Correct |
98 ms |
8792 KB |
Output is correct |
54 |
Correct |
52 ms |
8792 KB |
Output is correct |
55 |
Correct |
132 ms |
8824 KB |
Output is correct |
56 |
Correct |
29 ms |
8792 KB |
Output is correct |
57 |
Correct |
247 ms |
9672 KB |
Output is correct |
58 |
Correct |
243 ms |
9808 KB |
Output is correct |
59 |
Correct |
251 ms |
9636 KB |
Output is correct |
60 |
Correct |
266 ms |
10064 KB |
Output is correct |
61 |
Correct |
353 ms |
9640 KB |
Output is correct |
62 |
Correct |
353 ms |
9808 KB |
Output is correct |
63 |
Incorrect |
304 ms |
10064 KB |
Output isn't correct |
64 |
Halted |
0 ms |
0 KB |
- |