Input Specification:
3 2 1 3 0 2
620
Output Specification:
6
#include <iostream>
#include <algorithm>
using namespace std;
const int six = 6;
const int a[] = {1, 5, 10, 50, 100, 500};
int main()
{
int c[six];
int i, n, temp, count = 0, A;
for (i = 0; i < six; i++)
cin >> c[i];
cin >> A;
for (i = 5; i >= 0; i--)
{
temp = 0;
temp = min (A / a[i], c[i]);
A -= temp * a[i];
count += temp;
if (A == 0)
break;
}
cout << count;
return 0;
}