제출 #541917

#제출 시각아이디문제언어결과실행 시간메모리
541917AdamGSSelf Study (JOI22_ho_t2)C++17
100 / 100
274 ms11464 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define st first #define nd second #define pb push_back #define all(a) a.begin(), a.end() #define rep(a, b) for(int a = 0; a < (b); ++a) const int LIM=3e5+7; const ll INF=1e18+7; ll A[LIM], B[LIM], n, m; bool f(ll x) { ll ile=0; rep(i, n) { ll p=(x+A[i]-1)/A[i]; p=min(p, m); ll a=x-p*A[i]; ile+=p; if(a>0) ile+=(a+B[i]-1)/B[i]; if(ile>n*m) return false; } return true; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m; rep(i, n) cin >> A[i]; rep(i, n) { cin >> B[i]; A[i]=max(A[i], B[i]); } ll p=0, k=INF; while(p<k) { ll sr=(p+k+1)/2; if(f(sr)) p=sr; else k=sr-1; } cout << p << '\n'; }
#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...