Story of Berland
All submissions for this problem are available.
In West of Berland, there were two kings A and B who had conflicts between them. So, on a particular date they used battle fight to solve the dispute. Both of them had different armies.
Each soldier of the respective army had strength Si. Somehow, B found out the respective strength of each soldier of A's army before some battles.After this he was desperate to defeat A.
In order to defeat A, he had to choose his soldiers in such a way that a soldier of strength S would eliminate all the soldiers of A having strength S-1.
So king B asked you to find the number of soldiers he would require to defeat entire army of A.
- First line contains K the number of battles before which B knew the strength of A's army.
- Next K lines contains N the numbers of soldiers A was using before battle.
- Next line contains N space separated Strengths Si of army of A.
- Give the minimum number of soldiers B would require to defeat A for each battle.
- 1 <= K <= 100
- 1 <= N <= 100000
- 1 <= Si <= 1000000000
Input: 1 4 2 3 1 4 Output: 4
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions