알고리즘

[알고리즘] 백준 14720 - 우유 축제 (C++)

blueberrysoda 2024. 10. 3. 23:56

[문제 링크] : https://www.acmicpc.net/problem/14720

#include <iostream>
using namespace std;

int Arr[1001];

int main(){
    int N;
    cin >> N;
    
    int Ans = 0;
    int tmp = 0;

    for(int i=0; i<N; i++){
        cin >> Arr[i];
    }
    for(int i=0; i<N; i++){
        if(Arr[i] == 0 && tmp == 0){
            Ans++;
            tmp = 1;
        }
        if(Arr[i] == 1 && tmp == 1){
            Ans++;
            tmp = 2;
        }
        if(Arr[i] == 2 && tmp == 2){
            Ans++;
            tmp = 0;
        }
    }

    cout << Ans << "\n";
    
    return 0;
}