Submission #14309

#TimeUsernameProblemLanguageResultExecution timeMemory
14309Namnamseo볼질 (OJUZ10_ballparade)C++98
100 / 100
7 ms1084 KiB
#include <cstdio>
int n;
int ans;
int buf;
int ballcnt;
bool j1,j2,j3;
int main()
{
    scanf("%d",&n);
    for(;n--;){
        scanf("%d",&buf);
        if(buf==1){
            //puts("ball");
            ++ballcnt;
            if(ballcnt==4){
                //puts("");
                if(j1){
                    if(j2){
                        if(j3){
                            ++ans; j3=false;
                        }
                        j3=true; j2=false;
                    }
                    j2=true; j1=false;
                }
                j1=true;
                ballcnt=0;
            }
            
        } else if(buf==2){
            //puts("beanball\n");
            if(j1){
                if(j2){
                    if(j3){
                        ++ans; j3=false;
                    }
                    j3=true; j2=false;
                }
                j2=true; j1=false;
            }
            ballcnt=0;
            j1=true;
        } else {
            //puts("asdf");
            ++ballcnt;
            ans+=j3; j3=false;
            j3=j2; j2=false;
            j2=j1; j1=false;
            if(ballcnt==4) j1=true, ballcnt=0;
        }
        //printf("Current state %d %d %d\n",j1,j2,j3);
    }
    printf("%d\n",ans);
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...