Submission #1123516

#TimeUsernameProblemLanguageResultExecution timeMemory
1123516LucaIlieSelf Study (JOI22_ho_t2)C++20
0 / 100
396 ms2764 KiB
#include <bits/stdc++.h> using namespace std; const int MAX_N = 3e5; int a[MAX_N], b[MAX_N]; int main() { int n, m; cin >> n >> m; for ( int i = 0; i < n; i++ ) cin >> a[i]; for ( int i = 0; i < n; i++ ) cin >> b[i]; long long l = 0, r = 1e18; while ( r - l > 1 ) { long long mid = (l + r) / 2; long long freeClasses = (long long)n * m, busyClasses = 0; for ( int i = 0; i < n; i++ ) { if ( a[i] > b[i] ) { if ( (long long)a[i] * m >= mid ) freeClasses -= (mid + a[i] - 1) / a[i]; else { freeClasses -= m; busyClasses += (mid - (long long)m * a[i] + b[i] - 1) / b[i]; } } else busyClasses += (mid + b[i] - 1) / b[i]; } if ( freeClasses >= busyClasses ) l = mid; else r = mid; } cout << l << "\n"; }
#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...