Submission #1239183

#TimeUsernameProblemLanguageResultExecution timeMemory
1239183ebrambillSelf Study (JOI22_ho_t2)C++20
0 / 100
1095 ms5136 KiB
//In the name of GOD #include <bits/stdc++.h> using namespace std; const long long maxN=3e5+5; long long n, m, a[maxN], b[maxN]; bool can(long long x){ long long cnt=0; for (long long i=1; i<=n; i++){ cnt+=(a[i]<b[i] ? (cnt+=(x+b[i]-1)/b[i]) : (min((x+a[i]-1)/a[i], m)+((max(0LL, x-min((x+a[i]-1)/a[i], m)*a[i])+b[i]-1)/b[i]))); if(cnt>n*m) return false; } return true; } int main(){ cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); cin >>n >>m; for (long long i=1; i<=n; i++) cin >>a[i]; for (long long i=1; i<=n; i++) cin >>b[i]; long long l=0, r=LLONG_MAX; while(r-l>1){ long long mid=(r>>1)+(l>>1); if(can(mid)) l=mid; else r=mid; } cout <<l; }
#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...