Submission #885869

#TimeUsernameProblemLanguageResultExecution timeMemory
885869NintsiChkhaidzeSelf Study (JOI22_ho_t2)C++17
0 / 100
270 ms7616 KiB
#include <bits/stdc++.h> #define pb push_back #define s second #define f first #define pii pair<int,int> #define ll long long #define int ll using namespace std; const int N = 3e5 + 3; int a[N],b[N],n,m,cur[N]; bool check(int x){ int tot = 0; for (int i = 1; i <= n; i++){ cur[i] = max(a[i],b[i]) * m; if (cur[i] >= x){ tot += (x + max(a[i],b[i]) - 1)/max(a[i],b[i]); }else if (cur[i] < x){ tot += m + (x - cur[i] + b[i] - 1)/b[i]; } } if (tot > n*m) return 0; return 1; } signed main (){ ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL); cin>>n>>m; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n; i++) cin >> b[i]; int l = 0,r = 2e18,res=0; while (l <= r){ int mid = (l + r)/2; if (check(mid)){ res=mid; l=mid+1; }else{ r=mid-1; } } cout<<res; }
#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...