제출 #1295417

#제출 시각아이디문제언어결과실행 시간메모리
1295417hynmjSelf Study (JOI22_ho_t2)C++20
0 / 100
143 ms5128 KiB
#include <bits/stdc++.h> #define int long long using namespace std; const long long N = 300000 + 5; int a[N]; int b[N]; int n, m; bool possible(int k) { int saved = 0; for (int i = 0; i < n; i++) { int needed = (k + a[i] - 1) / a[i]; if (needed <= m) { saved += m - needed; continue; } int left = k - m * a[i]; assert(left >= 0); int others = (left + b[i] - 1) / b[i]; assert(others >= 0); saved -= others; } return saved >= 0; } void solve() { 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]); } int o = 0; for (int i = 62; i >= 0; i--) { int mask = 1ll << i; if (possible(o + mask)) { o += mask; } // cout << mask << endl; } cout << o; // cout << possible(38404721679817) << endl; } signed main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); int t = 1; // cin >> t; for (int i = 1; i <= t; i++) { // cout << "Case #" << i << ':' << ' '; solve(); cout << endl; } 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...