답안 #1018876

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1018876 2024-07-10T10:29:06 Z vjudge1 Snowball (JOI21_ho_t2) C++17
0 / 100
0 ms 344 KB
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
bool can_achieve_min_level(long long N,long long M,const vector<long long>& A,const vector<long long>& B,long long X) {
    long long total_lessons=N*M;
    long long lessons_needed=0;
    for(long long i=0; i<N; ++i) {
        if(A[i]>=X) {
            continue; 
        }
        long long lessons_to_attend=(X+A[i]-1)/A[i]; 
        lessons_needed+=lessons_to_attend;
    }
    return lessons_needed<=total_lessons;
}
long long maximize_min_level(long long N, long long M,const vector<long long>& A,const vector<long long>& B) {
    long long low=0,high=*max_element(A.begin(),A.end())*M; 
    while(low<high) {
        long long mid=(low+high+1)/2;
        if(can_achieve_min_level(N,M,A,B,mid)) {
            low=mid;
        } else {
            high=mid-1;
        }
    }
    return low;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    long long N,M;
    cin>>N>>M;
    vector<long long> A(N),B(N);
    for(long long i=0; i<N; ++i) {
        cin>>A[i];
    }
    for(long long i=0; i<N; ++i) {
        cin>>B[i];
    }
    long long result=maximize_min_level(N,M,A,B);
    cout<<result<<endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -