제출 #1154109

#제출 시각아이디문제언어결과실행 시간메모리
1154109dnnndaSelf Study (JOI22_ho_t2)C++20
62 / 100
1093 ms5136 KiB
#include<bits/stdc++.h> using namespace std; #define S second #define F first #define ll long long #define int long long //#pragma GCC optimize("Ofast, unroll-loop") //#pragma GCC target("avx,avx2") #pragma GCC optimize("O3") const int inf=0x3f3f3f3f; const ll inff=0x3f3f3f3f3f3f3f3f; const int X=998244353; int a[300005], b[300005]; ll divv(ll a, ll b){ // a/b return (a+b-1)/b; } signed main(){ ios::sync_with_stdio(0), cin.tie(0); int n; ll m; cin >> n >> m; for(int i=1 ; i<=n ; i++) cin >> a[i]; for(int i=1 ; i<=n ; i++) cin >> b[i]; for(int i=1 ; i<=n ; i++) a[i]=max(a[i],b[i]); auto ok=[&](ll goal)->bool{ //cout << "try: " << goal << '\n'; ll t=1LL*n*m; for(int i=1 ; i<=n ; i++){ ll c=divv(goal,a[i]); if(c<=m) t-=c; else{ ll req=goal-m*a[i]; t-=m+divv(req,b[i]); } //cout << c << ' ' << t << '\n'; if(t<0) return 0; } return t>=0; }; ll ans=0; for(ll jump=300'000'000'000'000LL ; jump ; jump>>=1){ while(ans+jump<=inff&&ok(ans+jump)) ans+=jump; } cout << ans << '\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...