Submission #1018599

#TimeUsernameProblemLanguageResultExecution timeMemory
1018599vicvicSelf Study (JOI22_ho_t2)C++11
62 / 100
195 ms5280 KiB
#include <iostream> #include <fstream> #define int unsigned long long using namespace std; const int nmax=3e5+5; int n, m, a[nmax], b[nmax]; bool check (int val) { int days=n*m; for (int i=1;i<=n;i++) { int filled=0; if (a[i]>b[i]) { int nr_act=min (days, m); if (nr_act*a[i]<val) { days-=nr_act; filled=nr_act*a[i]; } else { days-=val/a[i]+(val%a[i]!=0); continue; } } int nr_act=days; if (nr_act*b[i]<val-filled) { return 0; } days-=(val-filled)/b[i]+((val-filled)%b[i]!=0); if (days<0) { return 0; } } return 1; } int32_t main() { cin >> n >> m; for (int i=1;i<=n;i++) { cin >> a[i]; } for (int i=1;i<=n;i++) { cin >> b[i]; } int st=0, dr=1e18, poz=0; while (st<=dr) { int mij = (st+dr) >> 1; if (check (mij)) { st=mij+1; poz=mij; } else dr=mij-1; } cout << poz; 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...