COCI '17 Contest 5 #1 Olivander

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 1.0s
Memory limit: 64M

Problem types

Harry Potter has damaged his magic wand in a fight with Lord Voldemort. He has decided to get a new wand in Olivander's wand shop. On the floor of the shop, he saw N wands and N wand boxes. The lengths of the wands are, respectively, X_1, X_2, \dots, X_n, and the box sizes are Y_1, Y_2, \dots, Y_n. A wand of length X can be placed in a box of size Y if X \le Y. Harry wants to know if he can place all the wands in boxes so that each box contains exactly one wand.

Help him solve this difficult problem.

Input Specification

The first line of input contains the positive integer N (1 \le N \le 100), the number from the task.

The second line contains N positive integers X_i (1 \le X_i \le 10^9), the numbers from the task.

The third line contains N positive integers Y_i (1 \le Y_i \le 10^9), the numbers from the task.

Output Specification

If Harry can place all the wands in boxes, output DA (Croatian for yes), otherwise output NE (Croatian for no).

Scoring

In test cases worth 60\% of total points, it will hold N \le 9.

Sample Input 1

3
7 9 5
6 13 10

Sample Output 1

DA

Sample Input 2

4
5 3 3 5
10 2 10 10

Sample Output 2

NE

Sample Input 3

4
5 2 3 2
3 8 3 3

Sample Output 3

DA

Comments

There are no comments at the moment.