結果
問題 | No.672 最長AB列 |
ユーザー | Takuya Noguchi |
提出日時 | 2019-02-08 00:46:35 |
言語 | Ruby (3.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 310 bytes |
コンパイル時間 | 42 ms |
コンパイル使用メモリ | 11,504 KB |
実行使用メモリ | 37,612 KB |
最終ジャッジ日時 | 2023-09-08 15:45:55 |
合計ジャッジ時間 | 4,739 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 81 ms
15,252 KB |
testcase_01 | AC | 83 ms
15,132 KB |
testcase_02 | AC | 82 ms
15,072 KB |
testcase_03 | AC | 81 ms
15,152 KB |
testcase_04 | WA | - |
testcase_05 | AC | 81 ms
15,236 KB |
testcase_06 | AC | 82 ms
15,268 KB |
testcase_07 | AC | 80 ms
15,252 KB |
testcase_08 | AC | 81 ms
15,020 KB |
testcase_09 | AC | 218 ms
37,612 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 185 ms
28,216 KB |
testcase_14 | WA | - |
testcase_15 | AC | 187 ms
28,132 KB |
testcase_16 | AC | 187 ms
28,468 KB |
testcase_17 | AC | 200 ms
33,084 KB |
testcase_18 | WA | - |
コンパイルメッセージ
Syntax OK
ソースコード
answer = cumulative_sum = 0 distribution = Hash.new(-1) gets.chomp.chars.each_with_index do |char, i| cumulative_sum += char == 'A' ? 1 : -1 if distribution.key?(cumulative_sum) answer = [answer, i - distribution[cumulative_sum]].max else distribution[cumulative_sum] = i end end puts answer