Submission #1239165

#TimeUsernameProblemLanguageResultExecution timeMemory
1239165ebrambillSelf Study (JOI22_ho_t2)C++20
0 / 100
1096 ms328 KiB
//In the name of GOD #include <bits/stdc++.h> using namespace std; const int maxN=3e5+5; long long n, m, a[maxN], b[maxN]; bool can(long long x){ long long cnt=0; for (int i=1; i<=n; i++){ if(a[i]<b[i]) cnt+=(x+b[i]-1)/b[i]; else{ long long A=min((x+a[i]-1)/a[i], m), B=(max(0LL, x-A*a[i])+b[i]-1)/b[i]; cnt+=A+B; } 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 (int i=1; i<=n; i++) cin >>a[i]; for (int i=1; i<=n; i++) cin >>b[i]; long long l=0, r=1e18; 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...