제출 #1333295

#제출 시각아이디문제언어결과실행 시간메모리
1333295herissonwowwSelf Study (JOI22_ho_t2)C++20
25 / 100
99 ms2784 KiB
#include <bits/stdc++.h>

using namespace std;
const int N = 3e5+5;
int a[N], b[N];
bool can(long long mn, int n, int m){
    long long have = 1ll*n*m;
    long long need = 0;
    for(int i = 1; i<= n; i++){
        need += (mn+a[i]-1)/a[i];
        if(need>have)
            return 0;
    }
    return (have>=need);

}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    int n, m; cin >> n >> m;
    bool flag = true;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    for(int i = 1; i <= n; i++)
        cin >> b[i];
    /*
    if(m==1){
        int ans = 1e9+1;
        for(int i = 0; i < n; i++){
            ans = min(ans,max(a[i],b[i]));
        }
        cout << ans;
        return 0;
    }*/
    long long l = 1; long long r = 1e18+1;
    int maxval = n*m;
    while(l+1<r){
        long long mid = (l+r)/2;
        int need = 0;
        if(can(mid,n,m))
            l = mid;
        else
            r = mid;
    }
    cout << l;
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...