Submission #534171

#TimeUsernameProblemLanguageResultExecution timeMemory
534171LittleOrangeSelf Study (JOI22_ho_t2)C++17
0 / 100
343 ms4940 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; ll n,m; vector<pair<ll,ll> > dat; bool isok(ll target){ // ans>=target; ll time = 0; for (ll i = 0;i<n;i++){ ll a = m; ll t = target - a*dat[i].first; if (t<=-dat[i].first){ a -= (-t)/dat[i].first; t = target - a*dat[i].first; }else if (t>0){ a += t/dat[i].second; t -= t/dat[i].second*dat[i].second; if (t>0){ a++; } } time += a; } return time<=n*m; } ll check(ll l, ll r){ if (l >= r) return l; ll mid = (l+r)/2; if (isok(mid+1)){ return check(mid+1,r); }else{ return check(l,mid); } } int main(){ ios::sync_with_stdio(0);cin.tie(0); cin >> n >> m; dat.resize(n); for (ll i = 0;i<n;i++){ cin >> dat[i].first; } for (ll i = 0;i<n;i++){ cin >> dat[i].second; dat[i].first = max(dat[i].first, dat[i].second); } cout << check(0,5e18) << "\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...