Submission #887709

#TimeUsernameProblemLanguageResultExecution timeMemory
887709Maite_MoraleSelf Study (JOI22_ho_t2)C++14
100 / 100
371 ms13224 KiB
#include<bits/stdc++.h> #define F first #define S second #define MAX 500005 #define oo 1e18 #define mod 1000000007 #define fast_in ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout.setf(ios::fixed);cout.precision(0); using namespace std; typedef long long ll; #define pll pair<ll , ll> #define vll vector<ll> #define vvll vector<vll> #define vpll vector<pll> ll n,k; pll a[MAX]; ll OK(ll x){ __int128 m=k*n,r=0; for(int i=0;i<n;i++){ __int128 moves=min(k,(x+a[i].F-1)/a[i].F); r+=(max((__int128)0,x-(a[i].F*moves))+a[i].S-1)/a[i].S; m-=moves; } if(r<=m)return 1; return 0; } int main(){ fast_in cin>>n>>k; for(int i=0;i<n;i++){ cin>>a[i].F; } for(int i=0;i<n;i++){ cin>>a[i].S;a[i].F=max(a[i].S,a[i].F); } ll p=0,f=3*oo; while(abs(p-f)!=1){ ll m=(p+f)/2; if(OK(m)==1)p=m; else f=m; } cout<<p; 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...