atcoder#ABC226G. [ABC226G] The baggage
[ABC226G] The baggage
Score : points
Problem Statement
We have parcels with five different weights: , , , , . For each , there are parcels of weight . Additionally, we have people with five different strengths: , , , , . For each , there are people with strength . Each person can carry any number of parcels (possibly zero), but the total weight of the parcels must not exceed their strength.
You are given test cases. For each case, determine whether it is possible for the people to carry all parcels with the appropriate allocation of parcels. That is, determine whether it is possible to allocate each parcel to someone so that each person is allocated parcels whose total weight does not exceed their strength. It is fine to have someone who carries no parcels.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input. The first line contains the number of test cases :
Then, test cases follow, each in the following format:
Output
Print lines.
The -th line should contain Yes
if all parcels can be carried in the -th test case, and No
otherwise.
3
5 1 0 0 1
0 0 0 2 1
0 3 0 0 0
0 0 2 0 0
10000000000000000 0 0 0 0
0 0 0 0 2000000000000000
Yes
No
Yes
In the first test case, all parcels can be carried. Here is one way to do so:
- The first person with strength carries four parcels of weight .
- The second person with strength carries one parcel of weight and another of weight .
- The person with strength carries one parcel of weight .
In the second test case, one of the two people with strength has to carry two or more parcels of weight , which is impossible.