Submission #526418

#TimeUsernameProblemLanguageResultExecution timeMemory
526418benson1029Self Study (JOI22_ho_t2)C++14
100 / 100
421 ms5060 KiB
#include<bits/stdc++.h> using namespace std; long long n,m; long long a[300005], b[300005]; long long l, r, mid; bool check(long long x) { long long extra = 0, need = 0; for(int i=1; i<=n; i++) { if(a[i] > b[i]){ // study in class long long needed = (x + a[i] - 1) / a[i]; if(needed > m) { need += (x - a[i] * m + b[i] - 1) / b[i]; if(need > 1e18) return false; } else { extra += m - needed; } } else { // study at any time extra += m; need += (x + b[i] - 1) / b[i]; if(need > 1e18) return false; } } if(extra>=need) return true; else return false; } int main() { cin >> n >> m; for(int i=1; i<=n; i++) cin >> a[i]; for(int i=1; i<=n; i++) cin >> b[i]; l = 0; r = 1e18; while(l<r) { mid = (l+r+1)/2; if(check(mid)) l = mid; else r = mid - 1; } cout << l << "\n"; }
#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...