제출 #1325274

#제출 시각아이디문제언어결과실행 시간메모리
1325274husseinjuandaSelf Study (JOI22_ho_t2)C++20
100 / 100
96 ms5120 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m; cin >> n >> m;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    vector<int> b(n);
    for(int i = 0; i < n; i++){
        cin >> b[i];
        a[i] = max(a[i], b[i]);
    }
    int low = 1;
    int top = 1e18;
    int ns = 0;
    while(low <= top){
        int mid = (low + top)/2;
        long double gaperlu = 0;
        for(int i = 0; i < n; i++){
            if(a[i] * m >= mid){
                int j = (mid+a[i]-1)/a[i];
                j = m-j;
                gaperlu += j;
            }else{
                gaperlu -= ((mid - a[i]*m) + b[i] - 1)/b[i];
            }
        }
        if(gaperlu >= 0){
            low = mid+1;
            ns = mid;
        }else{
            top = mid-1;
        }
    }
    cout << ns << "\n";
    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...