Submission #1041220

#TimeUsernameProblemLanguageResultExecution timeMemory
1041220SoulKnightSelf Study (JOI22_ho_t2)C++17
0 / 100
118 ms5204 KiB
#include "bits/stdc++.h" using namespace std; #define ll long long #define ln '\n' const int N = 3e5 + 5; const ll INF = 5e18 + 5; ll n, m, a[N], b[N]; inline ll ceil(ll x, ll y) {return (x + y - 1) / y;} ll cnt(ll go_lesson, ll i, ll tar){ return (m - go_lesson) - max(0LL, ceil(tar - a[i] * go_lesson, b[i])); } 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]; // ll l = 7, r = 7, ans = 0; ll l = 0, r = INF, ans = 0; while (l <= r){ ll tar = (l + r) / 2; ll diff = 0; // diff = free - need for (int i = 0; i < n; i++){ diff += max(cnt(1, i, tar), cnt(0, i, tar)); } if (diff >= 0) {ans = tar; l = tar + 1;} else r = tar - 1; } cout << ans << ln; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); // int TT; cin >> TT; // while (TT--) {solve();} 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...