Submission #886573

#TimeUsernameProblemLanguageResultExecution timeMemory
886573dubabubaSelf Study (JOI22_ho_t2)C++14
25 / 100
324 ms7464 KiB
#include <bits/stdc++.h> using namespace std; #define int long long typedef long long ll; const int mxn = 3e5 + 10; const int mxm = 1e9 + 10; const int inf = 2e18 + 10; ll a[mxn], b[mxn], x[mxn]; int n, m; void build() { for(int i = 0; i < n; i++) { x[i] = a[i] * m; } } ll sus(ll s, ll a) { return (s + a - 1) / a; } bool can(ll MID) { ll MIN = 0, MAX = 0; for(int i = 0; i < n; i++) { if(x[i] < MID) MIN += (MID - x[i] + b[i] - 1) / b[i]; if(x[i] > MID) MAX += min(m, (x[i] - MID) / a[i]); MIN = min(MIN, inf); MAX = min(MAX, inf); } return MIN <= MAX; } signed main() { cin >> n >> m; for(int i = 0; i < n; i++) cin >> a[i]; for(int j = 0; j < n; j++) cin >> b[j]; build(); ll L = 0, R = 1e18 + 10; while(R - L > 1) { ll M = (L + R) / 2; if(can(M)) L = M; else R = M; } cout << L << '\n'; 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...