Submission #526684

#TimeUsernameProblemLanguageResultExecution timeMemory
526684couplefireSelf Study (JOI22_ho_t2)C++17
100 / 100
250 ms9640 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long int main(){ // freopen("a.in", "r", stdin); cin.tie(0)->sync_with_stdio(0); int n, m; cin >> n >> m; vector<ll> a(n), b(n); for(int i = 0; i<n; ++i) cin >> a[i]; for(int i = 0; i<n; ++i) cin >> b[i]; for(int i = 0; i<n; ++i) a[i] = max(a[i], b[i]); ll lo = 0, hi = 1e18; while(lo<hi){ ll mid = lo+(hi-lo+1)/2; ll cnt = 0; for(int i = 0; i<n; ++i){ if(a[i]*m>=mid) cnt += m-(mid+a[i]-1)/a[i]; else cnt -= (mid-a[i]*m+b[i]-1)/b[i]; if(cnt<-1ll*n*m) break; } if(cnt>=0ll) lo = mid; else hi = mid-1; } cout << lo << '\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...