結果
| 問題 |
No.672 最長AB列
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-01-26 17:18:16 |
| 言語 | Ruby (3.4.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 518 bytes |
| コンパイル時間 | 238 ms |
| コンパイル使用メモリ | 7,296 KB |
| 実行使用メモリ | 23,200 KB |
| 最終ジャッジ日時 | 2024-09-16 07:49:59 |
| 合計ジャッジ時間 | 4,521 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 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|
p 'hoge'
puts a_arr.index(i)
puts a_arr_reverse.index(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