Submission #749898

#TimeUsernameProblemLanguageResultExecution timeMemory
749898JellyTheOctopusSelf Study (JOI22_ho_t2)C++17
100 / 100
384 ms11440 KiB
#include <bits/stdc++.h> using namespace std; long long N, M; long long A[300001], B[300001]; bool check(long long X) { long long day = 0; for (int i = 1; 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 false; } return true; } int main() { cin >> N >> M; for (int i = 1; i <= N; i++) { cin >> A[i]; } for (int i = 1; i <= N; i++) { cin >> B[i]; A[i] = max(A[i], B[i]); } long long high = 1LL << 60; long long low = 0; while (high-low > 1) { long long mid = (low+high)/2; if (check(mid)) { low = mid; } else { high = mid; } } cout << low << "\n"; }
#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...