Coding Test - cpp/Greedy
[백준 11047: 동전 0] - C++
에드윈H
2021. 2. 8. 20:32
#include<iostream>
using namespace std;
int arr[10];
int main() {
int n, k;
cin >> n >> k;
for (int i = 0; i < n; i++)
{
cin >> arr[i];
}
int temp = n-1;
int high = arr[temp--];
while (k<high)
{
high = arr[temp--];
}
int result = 0;
while (0<k)
{
result += k / high;
k = k % high;
high = arr[temp--];
}
cout << result << endl;
return 0;
}