Submission #573019

#TimeUsernameProblemLanguageResultExecution timeMemory
573019groshiSelf Study (JOI22_ho_t2)C++17
0 / 100
479 ms5072 KiB
#include<iostream> using namespace std; #define int long long long long a[1000000],b[1000000]; long long n,m; bool ok(long long ile) { //cout<<"check "<<ile<<"\n"; long long wolne=0; for(int i=1;i<=n;i++) { if(b[i]>a[i]) a[i]=b[i]; long long ile_kursow_ja=ile/a[i]; if(ile%a[i]!=0) ile_kursow_ja++; if(ile_kursow_ja<=m) wolne+=(m-ile_kursow_ja); else{ long long reszta=ile-m*a[i]; long long dod=reszta/b[i]; if(reszta%b[i]!=0) dod++; wolne-=dod; } //cout<<ile_kursow_ja<<" "<<wolne<<"\n"; } if(wolne>=0) return 1; else return 0; } int32_t main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); 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 pocz=0,kon=2*1e18+1,sre,ostd; while(pocz<kon) { sre=(pocz+kon)/2; //cout<<sre<<": "<<ok(sre)<<"\n"; if(ok(sre)) { ostd=sre; pocz=sre+1; } else kon=sre; } cout<<ostd; 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...