Submission #686757

#TimeUsernameProblemLanguageResultExecution timeMemory
686757yaufungSelf Study (JOI22_ho_t2)C++17
0 / 100
486 ms5012 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); long long n, m; cin >> n >> m; vector<long long> a(n), b(n); for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { cin >> b[i]; } long long bot, top, mid; bot = 0; top = 1e18; while (bot <= top) { mid = (bot + top) / 2; long long remain = 0; for (int i = 0; i < n; i++) { long long need; if (b[i] >= a[i]) { remain += m; need = (mid - 1) / b[i] + 1; remain -= need; } else { need = (mid - 1) / a[i] + 1; if (need <= m) { remain += (m - need); } else { need = (mid - m * a[i] - 1) / b[i] + 1; remain -= need; } } } if (remain >= 0) bot = mid + 1; else top = mid - 1; } cout << top << "\n"; 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...