Submission #794463

#TimeUsernameProblemLanguageResultExecution timeMemory
7944631binSelf Study (JOI22_ho_t2)C++14
100 / 100
235 ms11448 KiB
#include <bits/stdc++.h> using namespace std; #define all(v) v.begin(), v.end() typedef long long ll; const int NMAX = 3e5 + 5; ll n, m, a[NMAX], b[NMAX]; int f(ll k){ ll p = 0; for(int i = 0; i < n; i++){ ll x = (k - 1) / a[i] + 1; if(x <= m) p += m - x; else p -= (k - a[i] * m - 1) / b[i] + 1; if(p < -1e18) return 0; } return p >= 0; } int main(void){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; for(int i = 0; i < n; i++) cin >> a[i]; for(int i = 0; i < n; i++) cin >> b[i], a[i] = max(a[i], b[i]); ll l = 1, r = 1e18, mid; while(l < r){ mid = (l + r + 1) / 2; if(f(mid)) l = mid; else r = mid - 1; } 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...