Guest User

product

a guest
Jul 13th, 2020
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4.  
  5. int main(){
  6.   cin.tie(0);
  7.   ios_base::sync_with_stdio(false);
  8.   int n,x;
  9.   cin>>n>>x;
  10.   int a[n];
  11.   for(int i=0;i<n;i++){
  12.     cin>>a[i];
  13.   }
  14.   sort(a,a+n);
  15.   int count=0;
  16.   int product=1;
  17.   for(int i=n-1;i>=0;i--){
  18.     product=product*a[i];
  19.     if(product>=x){
  20.       count++;
  21.       product=1;
  22.     }
  23.   }
  24.   cout<<count<<"\n";
  25.  
  26. }
Add Comment
Please, Sign In to add comment