-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathq2.cpp
More file actions
47 lines (43 loc) · 845 Bytes
/
q2.cpp
File metadata and controls
47 lines (43 loc) · 845 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
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++)
{
cin>>arr[i];
}
int cntmin =0;
int cntmx =0;
for(int i=0;i<n-2;i++)
{
if(arr[i]==0 && arr[i+1]==0)
{
cntmin+=0;
cntmx+=0;
}
if(arr[i]==0 && arr[i+1]==1)
{
cntmin+=1;
cntmx+=1;
}
if(arr[i]==1 && arr[i+1]==0)
{
cntmin+=0;
cntmx+=1;
}
if(arr[i]==1 && arr[i+1]==1)
{
cntmx+=2 ;
cntmin+=1;
}
}
cout<<cntmin<<" "<<cntmx;
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
return 0;
}