ZOJ Problem Set - 4094
BaoBao is brewing a magical potion. To brew this potion, $n$ types of ingredients, whose rank ranges from 1 to $n$, is needed. More precisely, for all $1 \le i \le n$, BaoBao needs at least $a_i$ pieces of rank-$i$ ingredients to make the potion, while he only has $b_i$ 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?
There are multiple test cases. The first line of the input contains an integer $T$ (about 100), indicating the number of test cases. For each test case:
The first line contains an integer $n$ ($1 \le n \le 100$), indicating the number of types of ingredients.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$), where $a_i$ indicates the number of rank-$i$ ingredients needed.
The third line contains $n$ integers $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$), where $b_i$ indicates the number of rank-$i$ ingredients BaoBao has in his storeroom.
For each test case output one line. If BaoBao is able to brew the potion, output "Yes" (without quotes), otherwise output "No" (without quotes).
2 3 3 3 1 1 2 5 3 3 1 2 5 2 1
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.
Author: WENG, Caizhi
Source: The 19th Zhejiang University Programming Contest Sponsored by TuSimple