結果

問題 No.672 最長AB列
ユーザー urutomurutom
提出日時 2019-04-04 00:16:56
言語 Ruby
(3.3.0)
結果
AC  
実行時間 228 ms / 2,000 ms
コード長 239 bytes
コンパイル時間 678 ms
コンパイル使用メモリ 11,516 KB
実行使用メモリ 32,004 KB
最終ジャッジ日時 2023-08-25 02:50:25
合計ジャッジ時間 4,834 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
15,264 KB
testcase_01 AC 79 ms
15,144 KB
testcase_02 AC 78 ms
15,136 KB
testcase_03 AC 77 ms
15,220 KB
testcase_04 AC 81 ms
15,304 KB
testcase_05 AC 77 ms
15,180 KB
testcase_06 AC 78 ms
15,140 KB
testcase_07 AC 80 ms
15,268 KB
testcase_08 AC 80 ms
15,124 KB
testcase_09 AC 228 ms
32,004 KB
testcase_10 AC 203 ms
24,720 KB
testcase_11 AC 203 ms
24,792 KB
testcase_12 AC 162 ms
17,532 KB
testcase_13 AC 164 ms
17,416 KB
testcase_14 AC 161 ms
17,712 KB
testcase_15 AC 161 ms
17,224 KB
testcase_16 AC 162 ms
17,572 KB
testcase_17 AC 206 ms
24,784 KB
testcase_18 AC 156 ms
17,708 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

s=gets.chomp
sum=[0]
s.each_byte{|b|sum << sum.last+(b==?A.ord ? 1 : -1)}

h={}
sum.each_with_index{|v,i|
  if h[v]
    h[v][1]=i
  else
    h[v]=[i,-1]
  end
}

max=0
h.each_value{|l,r|
  next if r==-1
  d=r-l
  max=d if d>max
}

puts max
0