也是水题,按要求 玩就行
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <cstring>
#include <vector>
using namespace std;
#define ll long long
#define maxn 100005
int N;
int K[maxn];
const int value[5] = { 1, 5, 10, 20, 50 };
int F[maxn][5];
int change[5];
int main()
{
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
scanf("%d", &N);
bool cando = true;
int sum = 0;
int last = 0;
int tmp;
for (int i = 0; i < N; ++i)
{
scanf("%d", &K[i]);
for (int j = 0; j < 5; ++j)
{
scanf("%d", &F[i][j]);
}
}
for (int i = 0; i < N; ++i)
{
sum = 0;
for (int j = 0; j < 5; ++j)
{
sum += F[i][j] * value[j];
change[j] += F[i][j];
}
last = sum - K[i];
for (int j = 4; j >= 0; --j)
{
if (last == 0)
break;
tmp = last / value[j];
if (change[j] < tmp)
{
if (j == 0)
{
cando = false;
break;
}
else
{
change[j] = 0;
last -= change[j] * value[j];
}
}
else
{
change[j] -= tmp;
last -= tmp*value[j];
}
}
if (cando == false)
break;
}
if (cando)
printf("yes\n");
else
printf("no\n");
//system("pause");
//while (1);
return 0;
}