Submission #703589

# Submission time Handle Problem Language Result Execution time Memory
703589 2023-02-27T18:15:47 Z niter Self Study (JOI22_ho_t2) C++14
0 / 100
1000 ms 212 KB
#include <iostream>
#include <vector>
#define loop(i,a,b) for(int i=a;i<b;i++)
using namespace std;
long long A[300050], B[300050];

int main(){
    int N, M;
    cin >> N >> M;
    loop(i,0,N) cin >> A[i];
    loop(i,0,N) cin >> B[i];
    loop(i,0,N) A[i] = max(A[i], B[i]);

    long long ok = 0, ng = 1LL << 60;
    auto check = [&](long long x) -> bool {
        long long day = 0;
        for(int i = 0; i < N; i++){
            if(x <= A[i] * M) day += (x + A[i] - 1) / A[i];
            else day += M + (x - A[i] * M + B[i] - 1) / B[i];
            if(day > N * M) return 0;
        }
        return 1;
    };
    while(ng != ok){
        long long mid = (ng + ok) / 2;
        if(check(mid)) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 1022 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1075 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1022 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1075 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1022 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -