fork download
  1. #include <iostream>
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4.  
  5. int main() {
  6. int t;
  7. cin >> t;
  8. for(int o = 0; o < t ; o++){
  9. int n , x;
  10. cin >> n >> x;
  11. int a[n];
  12. for(int i = 0 ; i < n ; i++)cin >> a[i];
  13. sort(a , a+n);
  14. int count = 0;
  15. if(x%a[n-1] == 0){
  16. cout << x/a[n-1] << endl;
  17. continue;
  18. }
  19. if(x > 2*a[n-1] ){
  20. while(x > 2*a[n-1]){
  21. x = x - a[n-1];
  22. count ++ ;
  23. }
  24. }
  25. for(int i = n-1 ; i > 0 ; i--){
  26. if(x + a[i-1] > a[i] && x < a[i-1] + a[i]){
  27. count+=2;
  28. break;
  29. }
  30. else if(x + a[i] > a[i] && x < a[i] + a[i])
  31. {
  32. count += 2;
  33. break;
  34. }
  35. }
  36. cout << count << endl;
  37. }
  38. return 0;
  39. }
Success #stdin #stdout 0s 4324KB
stdin
1
2 11
1 5
stdout
3