Submission #1053817

#TimeUsernameProblemLanguageResultExecution timeMemory
1053817AlebnSelf Study (JOI22_ho_t2)C++14
0 / 100
77 ms7512 KiB
#include <bits/stdc++.h> #define int long long using namespace std; void solve() { int n, m; cin >> n >> m; vector<int> a(n), b(n), arr(n); int res = INT_MAX; for(int i = 0; i < n; i++) cin >> a[i]; for(int i = 0; i < n; i++) { cin >> b[i]; arr[i] = m * max(a[i], b[i]); res = min(res, arr[i]); } int l = 0, r = 1e18, mid; while(l <= r) { mid = (l + r) / 2; int over = 0, under = 0; for(int i = 0; i < n; i++) { if(arr[i] >= mid) over += (arr[i] - mid) / max(a[i], b[i]); else under += (mid - arr[i]) / b[i] + ((mid - arr[i]) % b[i] ? 1 : 0); } if(over >= under) { l = mid + 1; res = max(res, mid); } else r = mid - 1; } cout << res << "\n"; } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); solve(); }
#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...