제출 #783904

#제출 시각아이디문제언어결과실행 시간메모리
783904borisAngelovSelf Study (JOI22_ho_t2)C++17
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 300005; int n; long long m; long long a[maxn]; long long b[maxn]; long long round_up(long long x, long long y) { if (x % y == 0) { return x / y; } return x / y + 1; } bool check(long long min_score) { unsigned long long free_lections = 0; for (int i = 1; i <= n; ++i) { if (b[i] >= a[i]) { long long curr = round_up(min_score, b[i]); free_lections += (m - curr); } else { long long curr_lections = round_up(min_score, a[i]); if (curr_lections <= m) { free_lections += (m - curr_lections); } else { long long add_lections = round_up(min_score - m * a[i], b[i]); free_lections -= add_lections; } } } return free_lections >= 0; } void fastIO() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int main() { fastIO(); cin >> n >> m; for (int i = 1; i <= n; ++i) { cin >> a[i]; } for (int i = 1; i <= n; ++i) { cin >> b[i]; } long long l = 0; long long r = 1e18; while (l <= r) { long long mid = (l + r) / 2; if (check(mid) == false) { r = mid - 1; } else { l = mid + 1; } } cout << r << endl; 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...