#P4613. Wand Matching

    ID: 17859 Type: Default 1000ms 256MiB

Wand Matching

Wand Matching

Harry Potter has damaged his magic wand in a fight with Lord Voldemort. He now finds himself in Olivander's wand shop where he sees N wands and N wand boxes. The lengths of the wands are \(X_1, X_2, \dots, X_N\) and the sizes of the boxes are \(Y_1, Y_2, \dots, Y_N\). A wand with length \(X\) can be placed in a box of size \(Y\) if and only if \(X \le Y\).

Determine if Harry can place all the wands into the boxes so that each box contains exactly one wand.

Input Format: The first line contains an integer \(N\), followed by a line with \(N\) integers representing the wand lengths, and another line with \(N\) integers representing the sizes of the boxes.

Output Format: Output Yes if it is possible to place every wand into a box that can accommodate it, otherwise output No.

inputFormat

The input consists of multiple lines:

  • The first line contains an integer \(N\) (1 \(\leq N \leq 10^5\)).
  • The second line contains \(N\) space-separated integers \(X_1, X_2, \dots, X_N\) representing the lengths of the wands.
  • The third line contains \(N\) space-separated integers \(Y_1, Y_2, \dots, Y_N\) representing the box sizes.

outputFormat

Output a single line containing either Yes if it is possible to place all the wands in boxes under the given conditions, or No otherwise.

sample

3
2 3 4
3 4 5
Yes