Preparing NOJ

Hack

1000ms 65536K

Description:

As we all know, Codeforces' regular games will carry out Hack activities in units of Rooms.

It is now known that $$$m$$$ teams participate in Codeforces competitions, and the $$$i$$$-th team includes $$$r_i$$$ players. Codeforces set up $$$n$$$ rooms, and $$$i$$$-th rooms can hold $$$c_i$$$ people.

In order to make the game fairer, there should not be two people in a room from the same team.

For example, there are now three teams, A, B, and C. Team A's players are $$$A_1, A_2, A_3$$$, and Team B's players are $$$B_1, B_2, B_3$$$, and Team C's players are $$$C_1, C_2, C_3$$$. If there are three rooms now, each room can accommodate up to three people, $$${A_1,B_1,C_1}, {A_2,B_2,C_2},{A_3,B_3,C_3}$$$ is a reasonable allocation.

Can you arrange a legal plan for Codeforces?

Input:

The first line contains two integers $$$m$$$ and $$$n$$$, where $$$1 \leq n, m \leq 300$$$.

The second line contains $$$m$$$ integers representing $$$r_{i}$$$, where $$$r_{i} \leq 150$$$.

The third line contains $$$n$$$ integers representing $$$c_{i}$$$, where $$$c_{i} \leq 150$$$.

Output:

If there exits a legal plan, output YES, otherwise output NO.

Sample Input:

3 3
3 3 3
3 3 3

Sample Output:

YES

Info

NOJ

Provider NOJ

Code NOJ2387

Tags

Submitted 148

Passed 39

AC Rate 26.35%

Date 08/15/2019 01:18:45

Related

Nothing Yet