Submission #1062322

#TimeUsernameProblemLanguageResultExecution timeMemory
1062322ducksaysquackSelf Study (JOI22_ho_t2)C++98
100 / 100
212 ms11376 KiB
#include <bits/stdc++.h> #define int long long using namespace std; signed main() { int n, k; cin >> n >> k; vector<int> a(n), b(n); int l = 0, r = 0; for(int i=0;i<n;i++) {cin >> a[i]; r = max(r,a[i]);} for(int i=0;i<n;i++) {cin >> b[i]; r = max(r,b[i]);} r *= k; while(l<r) { int m = l+(r-l+1)/2, c = 0; for(int i=0;i<n;i++) { if(m <= k*max(a[i],b[i])) c += (k-(m+max(a[i],b[i])-1)/max(a[i],b[i])); else c -= (m-k*max(a[i],b[i])+b[i]-1)/b[i]; if(c <= -n*k) {r = m-1; break;} } if(c >= 0) l = m; else r = m-1; } cout << l; }
#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...