Submission #1000519

#TimeUsernameProblemLanguageResultExecution timeMemory
1000519LCJLYSelf Study (JOI22_ho_t2)C++14
100 / 100
153 ms10936 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define ld long double #define show(x,y) cout << y << " " << #x << endl; #define show2(x,y,i,j) cout << y << " " << #x << " " << j << " " << #i << endl; #define show3(x,y,i,j,p,q) cout << y << " " << #x << " " << j << " " << #i << " " << q << " " << #p << endl; #define show4(x,y) for(auto it:y) cout << it << " "; cout << #x << endl; typedef pair<int,int>pii; typedef array<int,3>pi2; #define ll __int128 void solve(){ int n,m; cin >> n >> m; pii arr[n]; for(int x=0;x<n;x++){ cin >> arr[x].first; } for(int x=0;x<n;x++){ cin >> arr[x].second; arr[x].first=max(arr[x].first,arr[x].second); } int l=0; int r=1e18; int mid; int best=0; while(l<=r){ mid=(l+r)/2; ll counter=0; for(int x=0;x<n;x++){ ll hold=(mid+arr[x].first-1)/arr[x].first; if(hold<=m){ counter+=hold; } else{ counter+=m; ll hold2=(mid-arr[x].first*m); counter+=(hold2+arr[x].second-1)/arr[x].second; } } if(counter<=n*m){ best=mid; l=mid+1; } else r=mid-1; } cout << best; } int32_t main(){ ios::sync_with_stdio(0); cin.tie(0); int t=1; //cin >> t; //freopen("in.txt","r",stdin); while(t--){ solve(); } }
#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...