#P10317. [SHUPC 2024] 小A的皇室战争卡组
[SHUPC 2024] 小A的皇室战争卡组
Problem Description
Xiao A really likes playing the game Clash Royale. There are types of cards in Clash Royale: troops, buildings, and spells. A deck carries cards. A valid deck contains building cards, spell cards, and there is no restriction on troop cards. Each card has its own level and type .
Now Xiao A wants to have a friendly battle with Xiao B, so he needs to build a battle deck. Xiao A has cards in total. The type and level of each card are known, and the level of each battle card of Xiao B is known. Since Xiao A is very confident in his skill, as long as the average level of his battle cards the average level of the opponent's battle cards , and the deck is a valid deck, he can guarantee victory.
Now please help Xiao A think about it: can he guarantee victory?
Input Format
The first line contains an integer , indicating the number of test cases.
For each test case, the first line contains a positive integer , representing the total number of cards Xiao A has. It is guaranteed that .
The second line of each test case contains positive integers, representing the type of each card . Type represents a troop card, type represents a building card, and type represents a spell card.
The third line of each test case contains positive integers, representing the level of each card .
The fourth line of each test case contains positive integers, representing the level of each of Xiao B's cards .
Output Format
Output lines, each containing a string. If Xiao A can win, output Yes; otherwise output No.
3
10
2 3 3 3 1 1 1 1 1 1
7 8 9 1 2 3 4 5 6 6
13 13 13 13 3 3 3 3
10
2 2 3 1 1 1 1 1 1 1
10 9 2 2 2 2 2 2 2 2
5 5 5 5 5 5 5 6
8
1 1 1 1 1 1 1 1
15 15 15 15 15 15 15 15
1 1 1 1 1 1 1 1
Yes
No
No
Hint
Sample explanation:
In the first sample, Xiao A can choose cards . The average level of the battle deck is , while the average level of Xiao B's battle deck is . Since 's average level XiaoB's average level , Xiao A can guarantee victory.
In the second sample, no matter how Xiao A configures the deck, he cannot make the average level satisfy the condition, so he cannot win.
In the third sample, Xiao A cannot configure a valid deck, so he cannot win either.
Translated by ChatGPT 5