結果
問題 |
No.672 最長AB列
|
ユーザー |
|
提出日時 | 2018-05-03 15:22:31 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 456 bytes |
コンパイル時間 | 1,214 ms |
コンパイル使用メモリ | 157,292 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-28 00:43:42 |
合計ジャッジ時間 | 2,011 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 8 WA * 8 |
ソースコード
#include "bits/stdc++.h" #define fastcin {\ cin.tie(0);\ ios::sync_with_stdio(false);\ } using namespace std; int main() { fastcin; static char S[200000]; cin >> S; int c = 0, a = 0, t = -1; static int l = strlen(S); for(int i = 0; i < l; i++) { if(S[i]=='A') c++; else if(S[i]=='B') c--; if(c==0) { a += (i - t); t = i; } } cout << a << "\n"; return 0; }