結果
| 問題 | No.3847 Triple Balls Removal |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-11-03 15:25:03 |
| 言語 | C++23(gcc16) (gcc 16.2.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 48 ms / 2,000 ms |
| + 616µs | |
| コード長 | 674 bytes |
| 記録 | |
| コンパイル時間 | 1,360 ms |
| コンパイル使用メモリ | 189,988 KB |
| 実行使用メモリ | 7,424 KB |
| 最終ジャッジ日時 | 2026-12-04 20:52:46 |
| 合計ジャッジ時間 | 5,694 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
#include <iostream>
#include <stack>
using namespace std;
int main(){
// 入出力の高速化
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int N;
cin >> N;
int ans = 0;
stack<int> s;
s.push(-1);
s.push(-1);
for(int i=0; i<N; i++){
int c;
cin >> c;
s.push(c);
int top1 = s.top(); s.pop();
int top2 = s.top(); s.pop();
int top3 = s.top(); s.pop();
if(top1 == top2 && top2 == top3){
ans += 3;
}
else{
s.push(top3);
s.push(top2);
s.push(top1);
}
}
cout << ans << "\n";
return 0;
}