Submission #658840

#TimeUsernameProblemLanguageResultExecution timeMemory
658840GrandTiger1729Self Study (JOI22_ho_t2)C++17
100 / 100
249 ms11452 KiB
#include <iostream> using namespace std; const long long INF = 5e18; int main(){ cin.tie(0)->sync_with_stdio(0); long long n, m; cin >> n >> m; 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]; } auto check = [&](long long x) -> bool { long long cnt = 0; for (int i = 0; i < n; i++){ if (a[i] > b[i]){ if (a[i] * m >= x){ cnt += x / a[i] + (bool)(x % a[i]); }else{ cnt += m; long long y = x - m * a[i]; cnt += y / b[i] + (bool)(y % b[i]); } }else{ cnt += x / b[i] + (bool)(x % b[i]); } if (cnt > n * m){ return false; } } return true; }; long long l = 0, r = INF; while (l < r - 1){ long long mid = (l + r) / 2; if (check(mid)){ l = mid; }else{ r = mid; } } cout << l; 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...