Submission #640715

#TimeUsernameProblemLanguageResultExecution timeMemory
640715peter940324Self Study (JOI22_ho_t2)C++17
0 / 100
460 ms4996 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define double long double #define IO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define pii pair<int,int> #define ff first #define ss second #define mp make_pair #define pb push_back #define pf push_front #define all(x) x.begin(),x.end() #define de(x) cout << #x << ' ' << x << '\n'; template<class T> void prt(T l,T r){ while(l!=r) cout << *l << ' ',l++; cout << '\n'; } const int N=3e5+5,M=1e9+7,INF=1e18; int a[N],b[N]; int n,m; int test(int x){ int cnt=0; for(int i=0;i<n;i++){ if(a[i]>b[i]){ int y=(x+a[i]-1)/a[i]; if(y>m){ y=x-m*a[i]; cnt+=m+(y+b[i]-1)/b[i]; }else{ cnt+=y; } }else{ cnt+=(x+b[i]-1)/b[i]; } } return cnt<=n*m; } signed main(){ IO cin >> n >> m; for(int i=0;i<n;i++) cin >> a[i]; for(int i=0;i<n;i++){ cin >> b[i]; } int l=0,r=INF+1; while(r-l>1){ int mid=(l+r)/2; if(test(mid)){ l=mid; }else{ r=mid; } } cout << l << '\n'; 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...