結果
| 問題 |
No.672 最長AB列
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-01-26 15:30:42 |
| 言語 | Ruby (3.4.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 472 bytes |
| コンパイル時間 | 418 ms |
| コンパイル使用メモリ | 7,328 KB |
| 実行使用メモリ | 24,732 KB |
| 最終ジャッジ日時 | 2024-09-16 05:10:49 |
| 合計ジャッジ時間 | 4,761 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 6 TLE * 1 -- * 9 |
コンパイルメッセージ
Syntax OK
ソースコード
a = gets.chomp
max_length = 0
balanced_length = 0
(0..a.length).each do |i|
descend_str, ascend_str = a[0, i-1].to_s, a[i-1, a.length].to_s
balanced_length = descend_str.length if descend_str.count('A') == descend_str.count('B')
max_length = balanced_length if balanced_length >= max_length
balanced_length = ascend_str.length if ascend_str.count('A') == ascend_str.count('B')
max_length = balanced_length if balanced_length >= max_length
end
puts max_length