結果

問題 No.672 最長AB列
ユーザー gt_ham_bass
提出日時 2018-04-13 23:40:19
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 384 bytes
コンパイル時間 469 ms
コンパイル使用メモリ 55,300 KB
実行使用メモリ 13,888 KB
最終ジャッジ日時 2024-06-27 19:50:41
合計ジャッジ時間 4,353 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 6 TLE * 1 -- * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
using namespace std;

int i,ans,ANS;
string s;

int main() {
	std::cin >> s;
	
	int n = s.size();
	
	for(int j = 0; j < n;j++){
		ANS = 0;
		for(i = 0; i + j < n; i++){
			if(s[i+j] == 'A') ANS++;
			else if(s[i+j] == 'B') ANS--;
			std::cout << ANS << std::endl;
			if(ANS == 0) ans = max(ans,i+1);
			
		}
	}
	
	std::cout << ans << std::endl;
}
0