Submission #13957

#TimeUsernameProblemLanguageResultExecution timeMemory
13957kriii볼질 (OJUZ10_ballparade)C++14
100 / 100
7 ms1084 KiB
#include <stdio.h>

int sc,base[3];

void mv()
{
	if (base[2] && base[1] && base[0]){
		sc++;
	}
	else if (base[1] && base[0]){
		base[2] = 1;
	}
	else if (base[0]){
		base[1] = 1;
	}
	base[0] = 1;
}

int main()
{
	int N,bc=0; scanf ("%d",&N);
	while (N--){
		int x; scanf ("%d",&x);
		if (x == 2){
			bc = 0;
			mv();
		}
		else{
			if (x == 3){
				if (base[2]) sc++;
				for (int i=2;i>=1;i--) base[i] = base[i-1];
				base[0] = 0;
			}

			if (++bc == 4){
				bc = 0;
				mv();
			}
		}
	}
	printf ("%d\n",sc);

	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...