結果
問題 |
No.672 最長AB列
|
ユーザー |
|
提出日時 | 2019-02-08 00:46:35 |
言語 | Ruby (3.4.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 310 bytes |
コンパイル時間 | 43 ms |
コンパイル使用メモリ | 7,680 KB |
実行使用メモリ | 36,480 KB |
最終ジャッジ日時 | 2024-06-26 08:46:48 |
合計ジャッジ時間 | 3,710 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 WA * 6 |
コンパイルメッセージ
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