-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodeforces_Vacations.cpp
More file actions
34 lines (30 loc) · 1014 Bytes
/
Copy pathCodeforces_Vacations.cpp
File metadata and controls
34 lines (30 loc) · 1014 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
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
void solve(){
int n;
cin>>n;
vector<int> dp(3);
for(int i=0; i<n; i++){
int x;
cin>>x;
vector<int> tmp(3);
tmp[0] = max(dp[0],max(dp[1],dp[2])); //taking rest today
if(x==1 or x==3) //contest today, result
tmp[1] = max(dp[0],dp[2])+1; // = max result of (taking rest, going gym) yesterday +1;
if(x==2 or x==3) //gym today, result
tmp[2] = max(dp[0],dp[1])+1; // = max result of (taking rest, participating contest) yesterday + 1;
swap(dp, tmp);
}
int result = n - max(dp[0],max(dp[1],dp[2]));
cout<<result<<endl;
}
signed main(){
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
optimize();
solve();
return 0;
}