fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define int long long int
  4. #define double long double
  5. #define print(a) for(auto x : a) cout << x << " "; cout << endl
  6.  
  7.  
  8. const int M = 1000000007;
  9. const int N = 3e5+9;
  10. const int INF = 2e9+1;
  11. const int LINF = 2000000000000000001;
  12.  
  13. inline int power(int a, int b) {
  14. int x = 1;
  15. a %= M;
  16. while (b) {
  17. if (b & 1) x = (x * a) % M;
  18. a = (a * a) % M;
  19. b >>= 1;
  20. }
  21. return x;
  22. }
  23.  
  24.  
  25. //_ ***************************** START Below *******************************
  26.  
  27.  
  28.  
  29. //* Make sure ai+1 % ai == 0 for this problem
  30. vector<int> a;
  31.  
  32. int consistency(int n, int x){
  33.  
  34. sort(begin(a), end(a), greater<int>());
  35.  
  36. int ct = 0;
  37. for(int i=0; i<n; i++){
  38. if(x==0) break;
  39. ct += (x/a[i]);
  40. x = x%a[i];
  41. }
  42.  
  43. return ct;
  44. }
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52. void solve() {
  53.  
  54. int n, x;
  55. cin>> n >> x;
  56.  
  57. a.resize(n);
  58. for(int i=0; i<n; i++) cin >> a[i];
  59.  
  60. cout << consistency(n, x) << endl;
  61.  
  62.  
  63. }
  64.  
  65.  
  66.  
  67.  
  68.  
  69. int32_t main() {
  70. ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  71.  
  72. int t = 1;
  73. // cin >> t;
  74. while (t--) {
  75. solve();
  76. }
  77.  
  78. return 0;
  79. }
Success #stdin #stdout 0s 5320KB
stdin
6 297
100 50  10  5  1
stdout
10