BaoBao is brewing a magical potion. To brew this potion, types of ingredients, whose rank ranges from 1 to , is needed. More precisely, for all , BaoBao needs at least pieces of rank- ingredients to make the potion, while he only has pieces of these ingredients in his storeroom.
Fortunately, BaoBao is able to downgrade a higher rank ingredient to a lower rank one (this operation can be performed any number of times, including zero time). Is it possible that BaoBao can make the potion using the ingredients in his storeroom?
Input
There are multiple test cases. The first line of the input contains an integer (about 100), indicating the number of test cases. For each test case:
The first line contains an integer (), indicating the number of types of ingredients.
The second line contains integers (), where indicates the number of rank- ingredients needed.
The third line contains integers (), where indicates the number of rank- ingredients BaoBao has in his storeroom.
Output
For each test case output one line. If BaoBao is able to brew the potion, output “Yes” (without quotes), otherwise output “No” (without quotes).
Sample Input
2
3
3 3 1
1 2 5
3
3 1 2
5 2 1
Sample Output
Yes
No
Hint
For the first sample test case, BaoBao can downgrade one rank-3 ingredient to a rank-2 ingredient, and downgrade two rank-3 ingredients to two rank-1 ingredients.

思路;
从后面开始比较,将多余的加到低一等级的数目。相减比较正负,从而判断是否有足够的药水去配置。

#include<stdio.h>
long long a[110],b[110];
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n;
int i;
long long sum;
int flag=1;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%lld",&a[i]);
for(i=0;i<n;i++)
{
scanf("%lld",&b[i]);
}
if(a[n-1]>b[n-1])
printf("No\n");
else {
for(i=n-1;i>=0;i--)
{
sum=b[i]-a[i];
if(sum<0)
{
flag=0;
break;
}
b[i-1]+=sum;
}
if(flag)
printf("Yes\n");
else printf("No\n");
}
}
return 0;
}