forked from deepakgarg0802/MyCompetitiveCodingSolutions
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchefapar.cpp
50 lines (44 loc) · 1.03 KB
/
chefapar.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
38
39
40
41
42
43
44
45
46
47
48
49
50
#include<bits/stdc++.h>
#define MAX 1000000
#define DEBUG(x) do { std::cout << #x << ": " << x << " "; } while (0)
using namespace std;
int main()
{
int t,n,a[MAX]={0},i,j,flag;
long long due;
scanf("%d",&t);
while(t--){
scanf("%d",&n);
due=0;
for(i=0;i<n;++i){
scanf("%d",&a[i]);
}
j=1;
for(i=0;i<n;++i){
if(a[i]==0)
{
flag=0;
j=max(j,i+1);
for(;j<n;++j){
if(a[j]==1){
a[j]=0;
flag=1;
//++j;
break;
}
}
if(flag==1){
due+=100;
flag=0;
}
else//rest all are 0
{
due+=(n-i)*1100;
break;
}
}
}
printf("%lld\n",due);
}
return 0;
}