W razie problemów technicznych ze Szkopułem, prosimy o kontakt mailowy pod adresem [email protected].
Jeśli chciałbyś porozmawiać o zadaniach, rozwiązaniach lub problemach technicznych, zapraszamy na serwery Discord. Są one moderowane przez społeczność, ale członkowie zespołu technicznego też są tam aktywni.
A group of children came to a toy store. Each of them would like to buy a number of balloons. The children like diversity - none of them wants to have two balloons of the same colour. Help the shop-assistant to check whether orders of all children can be completed within the current assortment of the store.
Write a program that:
The first line of input contains two integers and (, ), separated by a single space and denoting the number of different colours of balloons that are present in the store and the number of children. The second line of input contains integers ( for ), separated by single spaces and denoting the quantities of balloons of respective colours. The third line of input contains integers ( for ), separated by single spaces and denoting the orders of respective children; means that the -th child would like to buy balloons, all having different colours.
The first and only line of output should contain a single word TAK (i.e. yes in Polish), if orders of all children can be completed, and NIE (i.e. no in Polish) otherwise.
For the input data:
4 3 3 2 1 3 1 3 4
the correct result is:
TAK
and for the input data:
4 3 3 2 1 3 1 4 4
the correct result is:
NIE
Task author: Jakub Radoszewski.