DCP-481: Maximum Number of Customer Lose Back to All Problems

Medium Data Structures > Basic Data Structures

Mango Inc is one of biggest company of tech world now a days. Sales team of Mango Inc decided to launch a new campaign for their latest product **“who_cares_what_is_that”** . Unfortunately this turned around as a disaster of their marketing history. Now they know why name of product is matter as customer do cares what they buy. Campaign run for n days and each day m number of customer comes to visit. They used another of their product **“I_am_the_best”** to count number of customer come each day. Unfortunately during post campaign postmortem it turned around a faulty system and for some days it count negative amount of customer which definitely not happen. Mango Inc CEO mr **‘matha_nosto’** is very angry for this. He wants to know maximum number of customer lose ( if I < j , if number of customer visit in I<sup>th</sup> day is greater than number of customer visit in J<sup>th</sup> day, surely there is some customer lose ) between any two days of the campaign. And also there may have some scenario where during campaign Mango Inc didn't lose any customer just like sample case number three. Input: ------ Input starts with an integer T (**1 <= T <= 1000**), denoting the number of test cases.Each case contains an integer n (**2 ≤ n ≤ 100000**). Here n corresponds to the number of days the campaign run and each of next n lines contains an integer m ( **absolute value of m is less than <= 1000000** ) , number of customer visit the campaign that day. Output: ------- For each test case, print a line **“Case x: y”** where x is replaced by the test case number and y is maximum number of customer lose by Mango Inc. Sample Input ------------ 3 2 100 20 4 4 3 2 1 4 1 2 3 4 Sample Output ------------- Case 1: 80 Case 2: 3 Case 3: -1

Problem Setter:

Shakil Ahmed

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 mahbubcseju Cpp 0.00s
02 Superstorm Cpp14 0.00s
03 shahidul_brur Cpp 0.00s
04 emrul Cpp 0.00s
05 pulak_ict_mbstu Cpp 0.00s
06 _GhOstMan_ Cpp 0.00s
07 shahed95 Cpp 0.00s
08 rabbycse Cpp 0.00s
09 _c_k_r_ Cpp 0.00s
10 Robbinb1993 Cpp 0.00s
11 prateepm Cpp14 0.01s
12 Bisnu039 Cpp 0.01s
13 aaman007 Cpp 0.01s
14 st3inum Cpp14 0.01s
15 ehsan_sshuvo96 Cpp 0.01s
16 31_ipn Cpp 0.01s
17 madcoder_ju Cpp 0.01s
18 limlimu Cpp 0.01s
19 marayhan C 0.01s
20 Fazle Cpp14 0.01s
21 mike Cpp 0.01s
22 mir003 Cpp 0.01s
23 kzvd4729 Cpp14 0.01s
24 Shafquat Cpp 0.01s
25 Naim_BSMRSTU Cpp 0.01s
26 muradhossen Cpp 0.01s
27 Shahriar_88 Cpp14 0.01s
28 neel71 Cpp 0.01s
29 Sarwar05 Cpp14 0.01s
30 tariqiitju Cpp14 0.01s
31 prodipdatta7 Cpp14 0.01s
32 Masum_ice Cpp 0.01s
33 shahadat191 Cpp 0.01s
34 Pure_Protea Cpp14 0.02s
35 Indrjit_BU Cpp 0.02s
36 mh755628 Cpp 0.02s
37 tanvirshossain Cpp 0.02s
38 Abid_Hasan Cpp 0.02s
39 subhashis_cse Cpp 0.03s
40 Tahmid Cpp14 0.03s
41 shaft Cpp14 0.04s
42 hrOarr Cpp 0.04s
43 SAIF_IIT8_JU Cpp 0.11s
44 Ataur Cpp 0.47s
45 rahilmalhotra001 Java 0.95s

Your feedback is our precious!

Or call +88 02 9853138 for support