結果

問題 No.3847 Triple Balls Removal
コンテスト
ユーザー りすりす/TwoSquirrels
提出日時 2026-12-03 20:01:54
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 521 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,398 ms
コンパイル使用メモリ 346,416 KB
実行使用メモリ 9,872 KB
最終ジャッジ日時 2026-12-04 21:20:33
合計ジャッジ時間 6,974 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge6_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

// This solution should be WA!

#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n;
  cin >> n;
  vector<int> a(n);
  for (auto& x : a) cin >> x;

  deque<int> s;
  auto removed = 0;
  for (const int x : a) {
    s.push_back(x);
    const int m = s.size();
    if (m >= 3 && s[m - 1] == s[m - 2] && s[m - 2] == s[m - 3]) {
      s.resize(m - 3);
      removed += 3;
    }
    if (ssize(s) > 100000) s.pop_front();
  }
  cout << removed << '\n';
}
0