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 anik_JU Cpp 0.04s
03 kamran_11b Cpp 0.04s
04 Misu_Dey Cpp 0.04s
05 shuvo_mbstu Cpp 0.05s
06 akashkumar2 C 0.05s
07 sk23 Cpp 0.05s
08 souravahmed C 0.05s
09 rabbycse Cpp14 0.05s
10 fuad036 Cpp14 0.05s
11 Naim_BSMRSTU Cpp 0.05s
12 Frdhsn Cpp 0.05s
13 bu_hridoy Cpp 0.05s
14 feodorv C 0.05s
15 prottoy919 Cpp 0.05s
16 Chayti_Saha98 Cpp14 0.05s
17 Ahb_arif Cpp 0.05s
18 mhiceiuk Cpp 0.05s
19 emrul Cpp 0.05s
20 Nur_Alam39 Cpp 0.05s
21 yasirnabil534 Cpp14 0.05s
22 mohibur Cpp 0.05s
23 rayhan50001 Cpp14 0.06s
24 Anubis Cpp 0.06s
25 int_elligent Cpp 0.06s
26 abu_rifat Cpp 0.06s
27 prateepm Cpp14 0.06s
28 Nasif_44th 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 mh755628 Cpp 0.10s
34 QuwsarOhi Cpp 0.10s
35 Riz1ahmed Cpp 0.10s
36 Zihad C 0.10s
37 Dragon_Curve Cpp 0.10s
38 pulak_ict_mbstu Cpp 0.10s
39 ArifKhanShubro Cpp 0.11s
40 terminator_c Cpp 0.11s
41 shahidullah_anik Cpp 0.11s
42 SakibAlamin Cpp14 0.11s
43 Tasmim Cpp14 0.12s
44 Himon_PUST Cpp 0.12s
45 anik_ewu Cpp14 0.12s
46 quazi_adib Cpp 0.12s
47 Farhan_mahbub Cpp 0.12s
48 profake Cpp 0.12s
49 iammarajul Cpp 0.12s
50 Bisnu039 Cpp 0.12s

Your feedback is our precious!

Or call +88 02 9853138 for support