結果

問題 No.672 最長AB列
ユーザー 🍮かんプリン
提出日時 2019-03-07 19:04:41
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 622 bytes
コンパイル時間 438 ms
コンパイル使用メモリ 57,244 KB
実行使用メモリ 13,760 KB
最終ジャッジ日時 2024-06-23 14:52:19
合計ジャッジ時間 3,996 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 6 TLE * 1 -- * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

int main(){
    int A_cnt,B_cnt;
    string s;
    cin >> s;
    for(int len = 200000; len >= 0; len -= 2)
    {
        for(int i = 0; i < (int)s.length() - len + 1; i++)
        {
            A_cnt = B_cnt = 0;
            for(int j = i; j < len + i; j++)
            {
                if (s[j] == 'A') {
                    A_cnt++;
                }
                else {
                    B_cnt++;
                }
            }
            if (A_cnt == B_cnt) {
                cout << len << endl;
                return 0;
            }
        }
    }
    return 0;
}
0