提出 #72026707


ソースコード 拡げる

#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <deque>
#include <iterator>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <utility>
#define open(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
const ll maxn=2e5+1;
ll n,a[maxn],dp[maxn];
stack<ll> s;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        s.push(a[i]);
        if(s.size()>=4)
        {
            int x=s.top();
            s.pop();
            int y=s.top();
            s.pop();
            int z=s.top();
            s.pop();
            int w=s.top();
            s.pop();
            if(!(x==y&&y==z&&z==w))
            {
                s.push(w);
                s.push(z);
                s.push(y);
                s.push(x);
            }
        }
    }
    cout<<s.size();
}

提出情報

提出日時
問題 C - 1D puyopuyo
ユーザ zjd2013
言語 C++23 (GCC 15.2.0)
得点 300
コード長 1224 Byte
結果 AC
実行時間 10 ms
メモリ 6460 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 3412 KiB
00_sample_01.txt AC 1 ms 3416 KiB
00_sample_02.txt AC 1 ms 3484 KiB
01_random_00.txt AC 1 ms 3552 KiB
01_random_01.txt AC 10 ms 5916 KiB
01_random_02.txt AC 9 ms 5564 KiB
01_random_03.txt AC 9 ms 5504 KiB
01_random_04.txt AC 9 ms 5428 KiB
01_random_05.txt AC 9 ms 5328 KiB
01_random_06.txt AC 9 ms 5856 KiB
01_random_07.txt AC 9 ms 5708 KiB
01_random_08.txt AC 9 ms 5776 KiB
01_random_09.txt AC 9 ms 5488 KiB
01_random_10.txt AC 9 ms 5464 KiB
01_random_11.txt AC 8 ms 5372 KiB
01_random_12.txt AC 7 ms 5072 KiB
01_random_13.txt AC 7 ms 5080 KiB
01_random_14.txt AC 7 ms 5152 KiB
01_random_15.txt AC 7 ms 5228 KiB
01_random_16.txt AC 10 ms 6460 KiB
01_random_17.txt AC 8 ms 5724 KiB