이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
using namespace std;
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
typedef long long LL;
typedef pair<int,int> pii;
#define pb push_back
#define mkp make_pair
#define F first
#define S second
#define iter(x) x.begin(),x.end()
#define REP(n) for (int __=n;__--;)
#define REP0(i,n) for (int i=0;i<n;++i)
#define REP1(i,n) for (int i=1;i<=n;++i)
const int maxn = 3e5+10, mod = 0;
const LL inf = 0;
int n;
LL m, a[maxn], b[maxn];
bool bs(LL t){
LL cnt = 0;
REP1(i, n){
if (b[i] > a[i]) cnt += m - (t + b[i] - 1) / b[i];
else if (a[i] * m >= t) cnt += m - (t + a[i] - 1) / a[i];
else cnt -= (t - a[i] * m + b[i] - 1) / b[i];
}
return cnt >= 0;
}
void solve(){
cin >> n >> m;
REP1(i, n) cin >> a[i];
REP1(i, n) cin >> b[i];
LL LB = 0, RB = 1e18;
while (LB != RB){
LL m = (LB + RB + 1) / 2;
if (bs(m)) LB = m;
else RB = m-1;
}
cout << LB;
}
int main(){
ios_base::sync_with_stdio(false); cin.tie(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... |