forked from Ouditchya/SPOJ
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRPLC.cpp
37 lines (27 loc) · 872 Bytes
/
RPLC.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// AC, ALGO : Adhoc.
// For any clarifications, contact me at : [email protected]
#include<cstdio>
using namespace std ;
int main()
{
int t , n , i , j ;
long long life , life_req , num ;
scanf("%d",&t) ;
for( i = 1 ; i <= t ; i++ )
{
life = life_req = 1 ;
scanf("%d",&n) ;
for( j = 0 ; j < n ; j++ )
{
scanf("%lld",&num) ;
life += num ;
if( life <= 0 )
{
life_req += ( life - 1 ) * ( -1 ) ;
life += ( life - 1 ) * ( -1 ) ;
}
}
printf("Scenario #%d: %lld\n",i,life_req) ;
}
return 0 ;
}