Wednesday, August 10, 2016

Codeforces 698A - Vacations

Unknown
#include<cstdio>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    int a[n];
    for (int i=0;i<n;i++)
        scanf("%d",&a[i]);
    int rest=0;
    int p=0;
    for (int i=0;i<n;i++)
    {
        if (a[i]==0){
            rest++;
            p=0;
        }
        else if (!p){
            p=a[i];
        }
        else if (p==3){
                p=a[i];
        }
        else if(p==2 && a[i]!=2 ){
            p=1;
        }
        else if(p==2 && a[i]==2 ){
            p=0;
            rest++;
        }
        else if(p==1 && a[i]!=1 ){
            p=2;
        }
        else if(p==1 && a[i]==1 ){
            p=0;
            rest++;
        }
    }
    printf("%d\n",rest);

    return 0;
}

Unknown

Studying at Shahjalal University of Science and Technology, Sylhet.

2 comments:

Coprights @ 2016,