結果
| 問題 | No.672 最長AB列 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-01-26 17:19:04 |
| 言語 | Ruby (4.0.6 + ac-library) |
| 結果 |
TLE
不安定
|
| 実行時間 | - |
| コード長 | 454 bytes |
| 記録 | |
| コンパイル時間 | 9 ms |
| コンパイル使用メモリ | 8,704 KB |
| 実行使用メモリ | 18,048 KB |
| 最終ジャッジ日時 | 2026-08-28 14:46:49 |
| 合計ジャッジ時間 | 4,956 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 6 TLE * 1 -- * 9 |
コンパイルメッセージ
Syntax OK
ソースコード
a = gets.chomp
max_length = 0
a_arr = []
current = 0
a_arr << current
a.chars do |c|
if c == "A"
current = current + 1
a_arr << current
end
if c == "B"
current = current - 1
a_arr << current
end
end
a_arr_reverse = a_arr.reverse
(a_arr.min..a_arr.max).each do |i|
tmp_max_length = a_arr.length - a_arr.index(i) - a_arr_reverse.index(i) - 1
max_length = tmp_max_length if tmp_max_length >= max_length
end
print max_length