Submission #886968

#TimeUsernameProblemLanguageResultExecution timeMemory
886968stefanneaguSelf Study (JOI22_ho_t2)C++17
100 / 100
206 ms11384 KiB
#include <bits/stdc++.h> #define int long long using namespace std; const int nmax = 3e5 + 1; int a[nmax], b[nmax], n, m; bool check(int x) { int 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 0; } return 1; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 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]); } int l = 0, r = 1e18, ans = 0; while(l <= r) { int mid = (l + r) / 2; if(check(mid) == true) { ans = mid; l = mid + 1; } else { r = mid - 1; } } cout << ans; 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...