제출 #1308229

#제출 시각아이디문제언어결과실행 시간메모리
1308229luvqroseSelf Study (JOI22_ho_t2)C++20
10 / 100
90 ms5108 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const ll nx=3e5+5; ll n, m, a[nx], b[nx], need, extra, l=1, r=4e18, x, c, cl, y, rm; int main() { cin.tie(NULL)->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]; } while (l<r) { x=(l+r+1)/2; for (int i=1; i<=n; i++) { c=max(a[i], b[i]); if (x/c*c==x) cl=x/c; else cl=x/c+1; if (cl>m) { rm=x-m*c; if (rm/b[i]*b[i]==rm*b[i]) rm=rm/b[i]; else rm=rm/b[i]+1; need=need+rm; } else extra=extra+m-cl; if (need>m*n) { break; } } if (extra>=need) { l=x; } else r=x-1; need=0; extra=0; } cout<<r; }
#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...