제출 #734866

#제출 시각아이디문제언어결과실행 시간메모리
734866rahidilbayramliSelf Study (JOI22_ho_t2)C++17
100 / 100
408 ms11312 KiB
#include<bits/stdc++.h> #define ll long long #define pll pair<ll, ll> #define pii pair<int, int> #define vl vector<ll> #define sl set<ll> #define pb push_back #define all(v) v.begin(), v.end() #define f first #define s second #define ld long double using namespace std; const int sz = 3e5+5; ll n, m, i, j; ll a[sz], b[sz]; bool check(ll mid) { ll need = 0; for(i = 0; i < n; i++) { ll have = max(a[i], b[i]) * m, val = mid / max(a[i], b[i]); if(mid % max(a[i], b[i])) val++; need += min(val, m); if(mid > have) need += ceil((ld)(mid-have) / (ld)(b[i])); if(need > n * m) return false; } return (need <= n * m); } int main() { cin >> n >> m; for(i = 0; i < n; i++) cin >> a[i]; for(i = 0; i < n; i++) cin >> b[i]; ll l = 1, r = 1e18, k = 0; while(l <= r) { ll mid = (l + r) / 2; if(check(mid)) { k = mid; l = mid + 1; } else r = mid - 1; } cout << k << "\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...