-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVacations.cpp
More file actions
36 lines (34 loc) · 730 Bytes
/
Vacations.cpp
File metadata and controls
36 lines (34 loc) · 730 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
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
int arr[2][n];
for(int i = 0; i < n; i++){
int a;
cin >> a;
if(a == 0){
arr[0][i] = 0;
arr[1][i] = 0;
}
else if(a == 1){
arr[0][i] = 0;
arr[1][i] = 1;
}
else if(a == 2){
arr[0][i] = 1;
arr[1][i] = 0;
}
else if(a == 3){
arr[0][i] = 1;
arr[1][i] = 1;
}
}
for(int i = 1; i < n; i++){
arr[0][i] += arr[1][i - 1];
arr[1][i] += arr[0][i - 1];
}
int temp = max(arr[0][n - 1], arr[1][n - 1]);
cout << n - temp << " ";
return 0;
}