-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path465B.cpp
More file actions
51 lines (50 loc) · 998 Bytes
/
465B.cpp
File metadata and controls
51 lines (50 loc) · 998 Bytes
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
51
#include <iostream>
#include <string>
#include <streambuf>
#include <fstream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <map>
#include <set>
#include <stdlib.h>
#include <cstdio>
#include <vector>
#include <queue>
#include <math.h>
using namespace std;
long long sum=0;
int numb[999999];
int main()
{
long long t,x=0,y=0,n,m,count=0,a,b;
cin >> t;
for(long long k=1;k<=t;k++)
{
cin >> numb[k];
if(k==1 && numb[k]==1)
{
count++;
x++;
}
else if(numb[k]==1)
{
if(numb[k-1]==1)
count++;
else if(x==0)
count++;
else if(x>0)
count+=2;
x++;
//cout << count << endl;
}
}
//if(x==0)
cout << count;
//else
//cout << count+1;
return 0;
}