PivotOJ

Oreperations Research

시간 제한: 7000ms메모리 제한: 1024MB출처: ICPC ECNA 2020-2021BOJ 21153

문제

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 nn cars, where car ii has capacity cic_i, 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 AA has rr carts, and cart AiA_i carries a load of aia_i. Similarly, queue BB has ss carts, and cart BiB_i carries a load of bib_i. Initially train car 11 is at the loading station, and carts A1A_1 and B1B_1 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 AA queue, the front cart in the BB 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 AA has three mine carts carrying loads 44, 33 and 22, queue BB has four mine carts carrying loads 11, 55, 22 and 22, and the train has three cars with capacities 88, 55 and 44.  The starting setup is shown in the leftmost image.  After (say) the first car in queue AA 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 AA.  This situation is shown in the second image, where  the first train car still has capacity 44 to be filled.  This can be accomplished by dumping ore from the front car of both queues AA and BB. 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 BB 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 BB.  Note that if the third train car had capacity 33 it could not be filled to full capacity.

Figure 1: Sample Input 11

입력

Input begins with a line containing three positive integers rr ss nn (r,s50,n100)r,s \leq 50, n \leq 100) indicating the number of carts in queues AA and BB and the number of train cars, respectively. This is followed by three lines containing the values a1,a2,,ara_1, a_2, \ldots, a_r, b1,b2,,bsb_1, b_2, \ldots, b_s, and c1,c2,,cnc_1, c_2, \ldots, c_n, the capacities of the AA carts, the BB carts and the train cars, respectively.  The maximum capacity of any cart is 200200 and the maximum capacity of any train car is 20000002\,000\,000

출력

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
코드를 제출하려면 로그인하세요.