DCP-420: Minimum Cost Back to All Problems

Easy Beginners Problems > Ad-hoc

You are given an array with **N** integer numbers. Your task is to make all the element value same. In each move, you may ***select any index and decreases the value of that index by 1***.<br> You have to print the minimum numbers of moves needed to make all the array element same. Input: ------ Input starts with an integer **T (1<=T<=20)**, denoting the number of test cases. Each case contains an integer **N (1 ≤ N ≤ 100000)** size of array. Next line contains N space separated integers, say **X (1<=X<=100000)** . Output: ------- For each case of input, print the minimum numbers of moves needed to make all the array element same. Sample Input ------------ 1 2 1 2 Sample Output ------------- 1 Explanation:<br> In a single move, you may select element at index 2 and decrease it by 1, so final array will be ={1,1} in which all the array values are same.

Problem Setter:

Bishal Gautam

Please login to submit solution to this problem.

Problem Limits

Language Time Limit (seconds)
C 1.00
C++ 1.00
C++14 1.00
C# 2.00
Go 2.00
Java 2.00
JavaScript 2.00
Objective-C 2.00
Perl 2.00
PHP 2.00
Python 2.00
Python3 2.00
Ruby 2.00
VB.Net 2.00

Problem Stats




# User Language Timing
01 FariD Cpp14 0.03s
02 Misu_Dey Cpp 0.04s
03 anik_JU Cpp 0.04s
04 kamran_11b Cpp 0.04s
05 akashkumar2 C 0.05s
06 refatul_fahad Cpp14 0.05s
07 bu_hridoy Cpp 0.05s
08 emrul Cpp 0.05s
09 feodorv C 0.05s
10 Chayti_Saha98 Cpp14 0.05s
11 Nur_Alam39 Cpp 0.05s
12 mohibur Cpp 0.05s
13 mhiceiuk Cpp 0.05s
14 souravahmed C 0.05s
15 shuvo_mbstu Cpp 0.05s
16 Ahb_arif Cpp 0.05s
17 sk23 Cpp 0.05s
18 Frdhsn Cpp 0.05s
19 Naim_BSMRSTU Cpp 0.05s
20 fuad036 Cpp14 0.05s
21 yasirnabil534 Cpp14 0.05s
22 prottoy919 Cpp 0.05s
23 Anubis Cpp 0.06s
24 rayhan50001 Cpp14 0.06s
25 prateepm Cpp14 0.06s
26 Nasif_44th Cpp 0.06s
27 int_elligent Cpp 0.06s
28 abu_rifat Cpp 0.06s
29 ss1230 Cpp14 0.08s
30 Masum_ice Cpp 0.09s
31 Debasish1610177113 C 0.09s
32 TarikulCSE C 0.10s
33 Riz1ahmed Cpp 0.10s
34 mh755628 Cpp 0.10s
35 pulak_ict_mbstu Cpp 0.10s
36 QuwsarOhi Cpp 0.10s
37 Dragon_Curve Cpp 0.10s
38 Zihad C 0.10s
39 SakibAlamin Cpp14 0.11s
40 shahidullah_anik Cpp 0.11s
41 ArifKhanShubro Cpp 0.11s
42 terminator_c Cpp 0.11s
43 Tasmim Cpp14 0.12s
44 jamil993 Cpp 0.12s
45 Sajal_Deb Cpp 0.12s
46 sakib_75 Cpp 0.12s
47 ikaadil Cpp 0.12s
48 Anik_Modak Cpp 0.12s
49 rafikul_islam_murad Cpp 0.12s
50 sk_roy Cpp14 0.12s

Your feedback is our precious!

Or call +88 02 9853138 for support