Advertisement
LZsolar

TOI11: กุลีแห่งท่าเรือ (Labor at the Deck)

Apr 24th, 2020
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. typedef long long int ll;
  4. ll n,m,co[1000010],mn=2e9;
  5.  
  6. ll find(ll x){
  7.     ll box=0;
  8.     for(int i=1;i<=m;i++){
  9.         box+=x/co[i];
  10.     }
  11.     return box;
  12. }
  13.  
  14. int main(){
  15.    scanf("%lld %lld",&m,&n);
  16.    
  17.    for(int i=1;i<=m;i++){
  18.        scanf("%lld",&co[i]);
  19.        mn=min(mn,co[i]);
  20.    }
  21.    ll f=mn,l=mn*n,ans=2e12;
  22.    while(f<=l){
  23.        ll mid=(f+l)/2;
  24.        if(find(mid)>=n){
  25.            l=mid-1;
  26.            ans=min(ans,mid);
  27.        }
  28.        else{
  29.            f=mid+1;
  30.        }
  31.    }
  32.     printf("%lld",ans);
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement