結果
問題 | No.672 最長AB列 |
ユーザー |
|
提出日時 | 2018-05-08 22:25:50 |
言語 | C++11 (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 464 bytes |
コンパイル時間 | 409 ms |
コンパイル使用メモリ | 56,328 KB |
実行使用メモリ | 13,760 KB |
最終ジャッジ日時 | 2024-06-28 02:32:57 |
合計ジャッジ時間 | 4,022 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 TLE * 1 -- * 9 |
ソースコード
#include <iostream> #include <string> using namespace std; int main(int argc, char* argv[]) { string S; cin>>S; int i,j; int sLen=S.length(); int maxLen=0; int ANum; int BNum; for (i=0;i<sLen;i++){ ANum=0; BNum=0; if (S[i]=='A'){ ANum++; }else{ BNum++; } for (j=i+1;j<sLen;j++){ if (S[j]=='A'){ ANum++; }else{ BNum++; } if (ANum==BNum && maxLen<2*ANum){ maxLen=2*ANum; } } } cout<<maxLen<<endl; return 0; }