제출 #595504

#제출 시각아이디문제언어결과실행 시간메모리
595504someoneSelf Study (JOI22_ho_t2)C++14
62 / 100
258 ms11452 KiB
#include <bits/stdc++.h> #define int long long using namespace std; const int N = 3e5 + 42, INF = 1e18 + 42; int n, m, a[N], b[N]; bool possible(int mini) { __int128_t need = 0; for(int i = 0; i < n; i++) if(m * a[i] < mini) need += (mini - m * a[i] + b[i] - 1) / b[i]; else need -= m - (mini + a[i] - 1) / a[i]; return need <= 0; } int dicho(int deb, int fin) { if(deb + 1 == fin) return deb; int mid = (deb + fin) >> 1; if(possible(mid)) return dicho(mid, fin); return dicho(deb, mid); } signed main() { ios::sync_with_stdio(false); 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]; for(int i = 0; i < n; i++) a[i] = max(a[i], b[i]); cout << dicho(0, INF); }
#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...