제출 #1131869

#제출 시각아이디문제언어결과실행 시간메모리
1131869lopkusSelf Study (JOI22_ho_t2)C++20
0 / 100
133 ms4936 KiB
#include <bits/stdc++.h> #define int long long using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m; cin >> n >> m; vector<int> a(n + 1, 0); vector<int> b(n + 1, 0); for(int i = 1; i <= n; i++) { cin >> a[i]; } for(int i = 1; i <= n; i++) { cin >> b[i]; } int l = 0, r = 1e18, ans = - 1; while(l <= r) { int mid = (l + r) / 2; int save = n * m; for(int i = 1; i <= n; i++) { int current = mid; if(a[i] > b[i]) { int cnt = min(m, (mid + a[i] - 1) / a[i]); save -= cnt; current -= cnt * a[i]; } if(current > 0) { save -= (current + b[i] - 1) / b[i]; } } if(save < 0) { r = mid - 1; } else { l = mid + 1; ans = mid; } } cout << ans; }
#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...