結果
問題 |
No.672 最長AB列
|
ユーザー |
![]() |
提出日時 | 2019-01-26 16:48:45 |
言語 | Ruby (3.4.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 320 bytes |
コンパイル時間 | 301 ms |
コンパイル使用メモリ | 7,424 KB |
実行使用メモリ | 41,216 KB |
最終ジャッジ日時 | 2024-09-16 05:53:47 |
合計ジャッジ時間 | 4,845 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 WA * 6 |
コンパイルメッセージ
Syntax OK
ソースコード
S = gets.strip L = S.size occurrences = Array.new( L * 2 + 2 ) { Array.new } occurrences[L] << 0 depth = 0 L.times do |i| depth += if S[i] == 'A' then 1 else -1 end occurrences[ L + depth ] << i end res = 0 occurrences.each do |ary| if !ary.empty? then res = [ res, ary.last - ary.first ].max end end puts res