I want Goodies
All submissions for this problem are available.Everybody wants goodies! Especially with the chef's swagger! But you need laddus to redeem them. There are n people in the HASH club and everyone has some laddus, but they are not sure that they have enough. To ensure that the maximum number of people have access to the goodies, they decide to form pairs of 2 and share the goodies. When A and B form a pair, they add their laddus and redeem them for 1 goodie which then they share. The president of HASH club asks you to tell him how many people would be left with no goodies after forming pairs and redeeming laddus. Pairs are formed in an optimal manner. (NOTE: People outside a pair cant share laddus or goodies) ###Input: - The first line of input contains n, the number of people in HASH club and k, the number of laddus required to redeem 1 goodie. - Next line contains n integers, denoting the number of laddus each student has. ###Output: Output the minimum of the number of people left without goodies after they form pairs and redeem their laddus. ###Constraints - 2<=n<=100000 - 1<=k<=1000000000 - n is even - each student can have at most 10^9 laddus and he may be unlucky and have 0 laddus :( ###Sample Input: 4 100 90 80 15 40 ###Sample Output: 0 ###EXPLANATION: (90,15) and (80,40) are the formed pairs. So, both groups can get goodie by redeeming laddus! Hence, nobody is left sad without the goodies.
|Tags||corp2018, easy, greedy, jatin_cpp, sorting|
|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, rust, SCALA, swift, 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, kotlin, PERL6, TEXT, SCM chicken, CLOJ, COB, FS|
Fetching successful submissions