結果

問題 No.672 最長AB列
ユーザー letrangerjpletrangerjp
提出日時 2018-04-13 23:52:05
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 257 bytes
コンパイル時間 649 ms
コンパイル使用メモリ 11,304 KB
実行使用メモリ 37,532 KB
最終ジャッジ日時 2023-09-10 04:13:05
合計ジャッジ時間 5,976 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
15,040 KB
testcase_01 AC 84 ms
15,104 KB
testcase_02 AC 85 ms
15,144 KB
testcase_03 AC 86 ms
15,320 KB
testcase_04 AC 84 ms
15,124 KB
testcase_05 AC 84 ms
15,124 KB
testcase_06 AC 84 ms
15,084 KB
testcase_07 AC 88 ms
15,272 KB
testcase_08 AC 85 ms
15,256 KB
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

S = gets.chomp.chars
A = [sum = 0]+S.map{|c|sum += c == ?A ? 1 : 0}
B = [sum = 0]+S.map{|c|sum += c == ?B ? 1 : 0}

ans = 0
(0...A.size).each{|l|
  (l...A.size).each{|r|
    if A[r] - A[l] == B[r] - B[l]
      ans = r - l if r - l > ans
    end
  }
}
p ans
0