結果
問題 | No.672 最長AB列 |
ユーザー | Junpei Kuriyama |
提出日時 | 2019-01-26 16:01:29 |
言語 | Ruby (3.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 554 bytes |
コンパイル時間 | 63 ms |
コンパイル使用メモリ | 11,520 KB |
実行使用メモリ | 144,892 KB |
最終ジャッジ日時 | 2023-10-14 10:14:52 |
合計ジャッジ時間 | 4,571 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 82 ms
15,356 KB |
testcase_01 | AC | 80 ms
15,040 KB |
testcase_02 | AC | 78 ms
15,144 KB |
testcase_03 | AC | 78 ms
15,192 KB |
testcase_04 | AC | 78 ms
15,036 KB |
testcase_05 | AC | 80 ms
15,180 KB |
testcase_06 | AC | 78 ms
15,232 KB |
testcase_07 | AC | 78 ms
15,128 KB |
testcase_08 | AC | 78 ms
15,164 KB |
testcase_09 | TLE | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
コンパイルメッセージ
Syntax OK
ソースコード
a = gets.chomp max_length = 0 (0..a.length).each do |i| descend_str_length = a[0, i].to_s.length descend_str_A = a[0, i].to_s.count('A') ascend_str_length = a[i, a.length].to_s.length ascend_str_A = a[i, a.length].to_s.count('A') balanced_length = descend_str_length / 2 == descend_str_A ? descend_str_A * 2 : 0 max_length = balanced_length if balanced_length >= max_length balanced_length = ascend_str_length / 2 == ascend_str_A ? ascend_str_A * 2 : 0 max_length = balanced_length if balanced_length >= max_length end puts max_length