Submission #996758

#TimeUsernameProblemLanguageResultExecution timeMemory
996758faqinyeagerSelf Study (JOI22_ho_t2)C++17
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int n, m; vector<ll> a, b; bool F(ll x){ int r = 0; for(int i = 0; i < n; i++){ if(x / a[i] >= m){ r += m - (x / a[i]) / m; } } for(int i = 0; i < n; i++){ if(x / a[i] < m){ if(r >= m - x / a[i]){ r -= m - x / a[i]; }else{ return 0; } } } return 1; } int main(){ cin >> n >> m; a.resize(n); b.resize(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 lx = 0, rx = 1LL << 60; while(rx - lx > 1){ ll mid = (rx + lx) / 2; if(F(mid)) rx = mid; else lx = mid; } cout << rx; }
#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...