Submission #538050

#TimeUsernameProblemLanguageResultExecution timeMemory
538050ddy888Self Study (JOI22_ho_t2)C++17
0 / 100
274 ms5004 KiB
#undef _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define int long long #define pb push_back #define fi first #define si second #define ar array typedef pair<int,int> pi; typedef tuple<int,int,int> ti; void debug_out() {cerr<<endl;} template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr<<" "<<to_string(H);debug_out(T...);} #define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__) int N, M; int A[300010], B[300010]; int good(int x) { int cnt = 0; for (int i = 1; i <= N; ++i) { int co, st; if (A[i] >= B[i]) { if (M * A[i] < x) { co = M; st = (x - (M * A[i]) + B[i] - 1) / B[i]; } else { co = (x + A[i] - 1) / A[i]; st = 0; } } else { st = (x + B[i] - 1) / B[i]; co = 0; } if (st * B[i] + co * A[i] < x) return 0; cnt += co + st; } return cnt <= M * N; } signed main() { fast; cin >> N >> M; for (int i = 1; i <= N; ++i) cin >> A[i]; for (int i = 1; i <= N; ++i) cin >> B[i]; int lo = 0, hi = 1e16; while (lo + 1 < hi) { int mid = (lo + hi) >> 1; if (good(mid)) lo = mid; else hi = mid; } cout << lo; 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...