fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int n,x;
  7. cin>>n>>x;
  8. int ans;
  9. int arr[n];
  10. for(int i=0;i<n;i++)
  11. {
  12. cin>>arr[i];
  13. }
  14. sort(arr,arr+n);
  15. int low=0,high=n-1;
  16. while(low<=high)
  17. {
  18. int mid=(low+high)/2;
  19. if(arr[mid]>x)
  20. {
  21. if(mid!=0 && arr[mid-1]>x)
  22. {
  23. high=mid-1;
  24. }
  25. else
  26. {
  27. ans=mid;
  28. break;
  29. }
  30. }
  31. else
  32. low=mid+1;
  33. }
  34. cout<<ans<<endl;
  35. return 0;
  36. }
Success #stdin #stdout 0.01s 5296KB
stdin
5
35
10
20
30
40
50
stdout
3