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.
While moving to a new compound the Byteotian Institute of Experimental Physics has encountered a logistical problem - the transfer of its vast collection of precision weights turned out to be non-trivial.
The Institute has a certain number of containers of limited strength at its disposal. As many weights as possible are to be put into the containers, the remaining ones will be discarded. There is no limit on the number of weights to be put in a container apart from the requirement of not exceeding its strength. A container may also be empty.
Any two weights in the Institute have a peculiar property: the mass of one of them is an integer multiple of the mass of the other. Particularly, they may have the same mass.
Write a programme which:
The first line of the standard input contains two integers and (), separated by a single space, denoting respectively: the number of containers and the number of weights. The second line of the standard input consists of integers ( for ), separated by single spaces, denoting the strengths of containers in milligrammes. In the third line there are integers ( for ), separated by single spaces, denoting masses of the weights in milligrammes.
The first and only line of the standard output should contain a single integer - the maximal number of weights that can be placed in the containers without exceeding their durability.
For the input data:
2 4 13 9 4 12 2 4
the correct result is:
3
Any three out of four - but not all four - weights can be placed in the containers.
Task author: Jakub Radoszewski.