Oreperations Research
题号:NC227009
时间限制:C/C++/Rust/Pascal 6秒,其他语言12秒
空间限制:C/C++/Rust/Pascal 1024 M,其他语言2048 M
64bit IO Format: %lld

题目描述

You run a massive mining facility that extracts ore from a mine and loads it onto long trains for shipment to factories around the nation. A train consists of  cars, where car  has capacity , indicating how many tons of ore it can carry. Ore is dropped into the train cars at an overhead loading station from two separate queues of mine carts that run on either side the train. As with the train cars, mine carts hold varying loads of ore. Queue  has  carts, and cart  carries a load of . Similarly, queue  has  carts, and cart  carries a load of . Initially train car  is at the loading station, and carts  and  are available to dump ore into it. The train car currently in the station can be given the load from the front cart in the  queue, the front cart in the  queue, or from both. If a cart doesn't dump its ore, it remains at the loading station; if it does dump its ore, it cycles back into the mine, loads up on ore, and rejoins the end of its queue. Meanwhile, the next cart in the queue moves into place and is available to dump ore.  Carts may not drop partial loads of ore and may not leave the loading station until they've emptied.  Similarly train cars may not be over-filled and may not leave the loading station until they are filled to capacity.  As soon as a train car is filled to capacity it leaves the loading station and the next train car pulls in. Your task is to determine whether given sequences of mine carts can be used to fill a given sequence of train cars to their capacity.
Figure 1 shows an example of the process.  Here queue  has three mine carts carrying loads  and , queue  has four mine carts carrying loads  and , and the train has three cars with capacities  and .  The starting setup is shown in the leftmost image.  After (say) the first car in queue  dumps its load into the first train car it goes back to the mine and (eventually) returns to the end of the line in queue .  This situation is shown in the second image, where  the first train car still has capacity  to be filled.  This can be accomplished by dumping ore from the front car of both queues  and . Once filled, the first train car moves out of the loading station leaving an alignment of cars and carts shown in the third image.  Here, the only way to fill the train car is for the front car of queue  to dump its load.  This leads to the final image.  Here the last train car can be filled either by the front cars of both queues or the first two cars of queue .  Note that if the third train car had capacity  it could not be filled to full capacity.

Figure 1: Sample Input 

输入描述:

Input begins with a line containing three positive integers    ( indicating the number of carts in queues  and  and the number of train cars, respectively. This is followed by three lines containing the values , and , the capacities of the  carts, the  carts and the train cars, respectively.  The maximum capacity of any cart is  and the maximum capacity of any train car is 

输出描述:

Output Yes or No indicating whether all of the train cars can be filled to capacity.
示例1

输入

复制
3 4 3
4 3 2
1 5 2 2
8 5 4

输出

复制
Yes
示例2

输入

复制
3 4 3
4 3 2
1 5 2 2
8 5 3

输出

复制
No