Submission #658839

#TimeUsernameProblemLanguageResultExecution timeMemory
658839GrandTiger1729Self Study (JOI22_ho_t2)C++17
0 / 100
315 ms4992 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]); } } return cnt <= n * m; }; 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...