提出 #72055052


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();}
	return x*f;
}
void out(int x)
{
    if(x<0)putchar('-'),x=-x;
    if(x<10)putchar(x+'0');
    else out(x/10),putchar(x%10+'0');
}
int n;
stack<int>q;
int main(){
	n=read();
	for(int i=1;i<=n;i++){
		int p=read();
		q.push(p);
		if(q.size()>=4){
			int a=q.top();
			q.pop();
			int b=q.top();
			q.pop();
			int c=q.top();
			q.pop();
			int d=q.top();
			q.pop();
			if(!(a==b&&b==c&&c==d)){
				q.push(d);
				q.push(c);
				q.push(b);
				q.push(a);
			}
		}
	}
	cout<<q.size();
	return 0;
}

提出情報

提出日時
問題 C - 1D puyopuyo
ユーザ Fireflies
言語 C++23 (GCC 15.2.0)
得点 300
コード長 745 Byte
結果 AC
実行時間 6 ms
メモリ 4440 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 3
AC × 21
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 1 ms 3536 KiB
00_sample_01.txt AC 1 ms 3512 KiB
00_sample_02.txt AC 1 ms 3536 KiB
01_random_00.txt AC 1 ms 3500 KiB
01_random_01.txt AC 6 ms 4160 KiB
01_random_02.txt AC 6 ms 3956 KiB
01_random_03.txt AC 6 ms 3800 KiB
01_random_04.txt AC 6 ms 3776 KiB
01_random_05.txt AC 6 ms 3800 KiB
01_random_06.txt AC 6 ms 3928 KiB
01_random_07.txt AC 6 ms 3920 KiB
01_random_08.txt AC 6 ms 3884 KiB
01_random_09.txt AC 6 ms 3920 KiB
01_random_10.txt AC 6 ms 3888 KiB
01_random_11.txt AC 5 ms 3808 KiB
01_random_12.txt AC 5 ms 3576 KiB
01_random_13.txt AC 5 ms 3560 KiB
01_random_14.txt AC 5 ms 3572 KiB
01_random_15.txt AC 5 ms 3436 KiB
01_random_16.txt AC 6 ms 4440 KiB
01_random_17.txt AC 5 ms 4064 KiB