Submission #1131873

#TimeUsernameProblemLanguageResultExecution timeMemory
1131873lopkusSelf Study (JOI22_ho_t2)C++20
0 / 100
91 ms4936 KiB
#include <bits/stdc++.h> #define int long long using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m; cin >> n >> m; vector<int> a(n + 1, 0); vector<int> b(n + 1, 0); 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 = - 1; while(l <= r) { int mid = (l + r) / 2; int save = 0; for(int i = 1; i <= n; i++) { if(m * a[i] < mid) { save -= (mid - a[i] * m + b[i] - 1) / b[i]; } else { save += m - (mid + a[i] - 1) / a[i]; } } if(save < 0) { r = mid - 1; } else { l = mid + 1; ans = mid; } } cout << ans; }
#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...