This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
#define double long double
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 = (int)9e18 + (int)10;
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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |