Submission #1287422

#TimeUsernameProblemLanguageResultExecution timeMemory
1287422nasjesSelf Study (JOI22_ho_t2)C++20
0 / 100
136 ms9312 KiB
#include <iostream> #include <iomanip> #include <vector> #include <cmath> #include <algorithm> #include <set> #include <queue> #include <map> #include <stack> #include <bitset> #include <string> #include <cstring> #include <iterator> #include <random> using namespace std; typedef long long ll; typedef pair<ll, ll> pll; typedef long double ld; const ll dim = 1e6+7; const ll inf = 1e18 + 77; #define endl "\n" #define fi first #define pb push_back #define se second #define vll vector<ll> ll n, m; ll a[dim], b[dim]; ll check(ll val){ ll free=0; vector<pll> v; for(int i=1; i<=n; i++){ ll f=m-(val+a[i]-1)/a[i]; if(f>0)free+=f; else v.pb({val-a[i]*m, b[i]}); if(free>1e18)return 1; } for(auto el: v){ free-=(el.fi+el.se-1)/el.se; } if(free>=0)return 1; else return 0; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>m; for(int i=1; i<=n; i++) { cin>>a[i]; } for(int i=1; i<=n; i++) { cin>>b[i]; a[i]=max(a[i], b[i]); } ll l=1; ll r=1e18+7; while(r-l>=1){ ll mid=(l+r+1)/2; if(check(mid)){ l=mid; } else{ r=mid-1; } } cout<<l<<endl; 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...