A Fat Wallet (AOJ 0296) by ynu_e
Contest: 3421    RunID: 2277125    Status: Wrong Answer    Date: Sun Apr 23 16:11:06 JST 2017


#include<iostream>

using namespace std;

int cal_money(int money, int coin_N[])
{
	int coins[6] = { 1,5,10,50,100,500 };
	int okay = 0;

	for (int i = 5; i>0; i--)
	{
		for (; coin_N[i]>0; coin_N[i]--)
		{
			if (money == 0)
			{
				okay = 1; break;
			}
			money -= coins[i];
		}
	}

	return okay;

}

int main(void)
{
	int coin_N[5];
	int okay;

	for (int i = 0; i<6; i++)
		cin >> coin_N[i];

	okay = cal_money(1000, coin_N);

	cout << okay << endl;

	return 0;

}