Submission #833794

#TimeUsernameProblemLanguageResultExecution timeMemory
833794LeVanThucSelf Study (JOI22_ho_t2)C++17
100 / 100
309 ms13840 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define fi first #define se second #define p(x,y) pair<ll,ll>(x,y) #define BIT(i,x) ((x>>i)&1) #define MASK(x) (1<<x) #define ld long double #define __builtin_popcount __builtin_popcountll #define pll pair<ll,ll> template<class T1,class T2> bool maximize(T1 &x,const T2 &y) { if(x<y) { x=y; return 1; } return 0; } template<class T1,class T2> bool minimize(T1 &x,const T2 &y) { if(x>y) { x=y; return 1; } return 0; } void online() { std::ios_base::sync_with_stdio(0); cin.tie(0); #ifdef thuc freopen("input.inp", "r", stdin); freopen("output.out","w", stdout); #else #endif } const ll N=1e6+10; ll n,m; ll a[N],b[N],c[N]; ll check(ll x) { ll le=0; for(int i=1;i<=n;i++) { c[i]=0; if(a[i]>b[i]) { ll z=min(m,(x+a[i]-1)/a[i]); c[i]=a[i]*z; le+=(m-z); } else le+=m; } for(int i=1;i<=n;i++) { if(c[i]<x) le-=max(0ll,(x-c[i]+b[i]-1)/b[i]); if(le<0) return 0; } return 1; } int main() { online(); cin>>n>>m; for(int i=1;i<=n;i++) { cin>>a[i]; } for(int j=1;j<=n;j++) { cin>>b[j]; } ll base=0,d=1e18; while(d) { while(check(base+d)) base+=d; d/=2; } cout<<base; }
#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...