From df9a9349c14fec1c1fea9411cbc4d6a2ed984943 Mon Sep 17 00:00:00 2001 From: technicalreju <73017717+technicalreju@users.noreply.github.com> Date: Sun, 2 Oct 2022 10:20:34 +0530 Subject: [PATCH] Minimum Start Value Problem Statement -: Raman was playing a game, in starting he has x coins at some point of the game he has to pay some coins to get into the next level of the game, during each game he can collect some coins. If at anypoint of the game numbers of coins of Raman is less than one he will lose the game. Find the minimum value of x such that Raman wins. --- Minimum Start value.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Minimum Start value.cpp diff --git a/Minimum Start value.cpp b/Minimum Start value.cpp new file mode 100644 index 0000000..d81a537 --- /dev/null +++ b/Minimum Start value.cpp @@ -0,0 +1,11 @@ +n=int(input()) +arr=[] +for i in range(n): + arr.append(int(input())) +s,a=0,0 +for i in arr: + s=s+i + if(s<1): + a=a+(-1*s)+1 + s=1 +print(a)