#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m;
vector<pair<ll,ll> > dat;
bool isok(ll target){ // ans>=target;
ll time = 0;
for (int i = 0;i<n;i++){
ll a = min(((target-1)/dat[i].first)+1,m);
ll t = target - a*dat[i].first;
time += a;
if (t>0){
time += ((t-1)/dat[i].second)+1;
}
}
return time<=n*m;
}
ll check(ll l, ll r){
if (l >= r) return l;
ll mid = (r-l+1)/2+l;
if (isok(mid)){
return check(mid,r);
}else{
return check(l,mid-1);
}
}
int main(){
ios::sync_with_stdio(0);cin.tie(0);
cin >> n >> m;
dat.resize(n);
for (int i = 0;i<n;i++){
cin >> dat[i].first;
}
for (int i = 0;i<n;i++){
cin >> dat[i].second;
dat[i].first = max(dat[i].first, dat[i].second);
}
cout << check(1LL,1000000000000000000LL) << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 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 |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
4 ms |
332 KB |
Output is correct |
11 |
Correct |
228 ms |
4940 KB |
Output is correct |
12 |
Correct |
225 ms |
4940 KB |
Output is correct |
13 |
Correct |
238 ms |
4940 KB |
Output is correct |
14 |
Incorrect |
474 ms |
4940 KB |
Output isn't correct |
15 |
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 |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
120 ms |
2636 KB |
Output is correct |
10 |
Correct |
78 ms |
1868 KB |
Output is correct |
11 |
Correct |
56 ms |
1484 KB |
Output is correct |
12 |
Correct |
47 ms |
1228 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
0 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 |
Incorrect |
10 ms |
332 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 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 |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
4 ms |
332 KB |
Output is correct |
11 |
Correct |
228 ms |
4940 KB |
Output is correct |
12 |
Correct |
225 ms |
4940 KB |
Output is correct |
13 |
Correct |
238 ms |
4940 KB |
Output is correct |
14 |
Incorrect |
474 ms |
4940 KB |
Output isn't correct |
15 |
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 |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
120 ms |
2636 KB |
Output is correct |
10 |
Correct |
78 ms |
1868 KB |
Output is correct |
11 |
Correct |
56 ms |
1484 KB |
Output is correct |
12 |
Correct |
47 ms |
1228 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
0 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 |
Incorrect |
10 ms |
332 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 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 |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
4 ms |
332 KB |
Output is correct |
11 |
Correct |
228 ms |
4940 KB |
Output is correct |
12 |
Correct |
225 ms |
4940 KB |
Output is correct |
13 |
Correct |
238 ms |
4940 KB |
Output is correct |
14 |
Incorrect |
474 ms |
4940 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |