fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int n, k, sum;
  6. int arr[10];
  7.  
  8. int main(void)
  9. {
  10. cin >> n >> k;
  11. for (int i = 0; i < n; i++)
  12. cin >> arr[i];
  13.  
  14. for (int i = n - 1; i >= 0; i--)
  15. {
  16. if (k >= arr[i])
  17. {
  18. sum += k / arr[i];
  19. k %= arr[i];
  20. }
  21. }
  22. cout << sum;
  23. return 0;
  24. }
Success #stdin #stdout 0s 4920KB
stdin
10 4790
1
5
10
50
100
500
1000
5000
10000
50000
stdout
12