Submission #969202

#TimeUsernameProblemLanguageResultExecution timeMemory
969202yellowtoadSelf Study (JOI22_ho_t2)C++17
0 / 100
281 ms5300 KiB
#include <iostream> #include <algorithm> #define f first #define s second using namespace std; long long n, m, a[300010], b[300010], l = 0, r = 4e14, mid, cnt, req; bool check() { cnt = req = 0; for (int i = 1; i <= n; i++) { if (b[i] > a[i]) { cnt += m; req += (mid+b[i]-1)/b[i]; } else { if (a[i]*m >= mid) cnt += (a[i]*m-mid)/a[i]; else req += (mid-a[i]*m+b[i]-1)/b[i]; } } if (cnt < req) return 0; else return 1; } int main() { cin >> n >> m; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n; i++) cin >> b[i]; while (l <= r) { mid = (l+r)/2; if (!check()) r = mid-1; else l = mid+1; } cout << r << endl; }
#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...