結果
問題 | No.672 最長AB列 |
ユーザー | torus711 |
提出日時 | 2019-01-26 16:48:45 |
言語 | Ruby (3.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 320 bytes |
コンパイル時間 | 654 ms |
コンパイル使用メモリ | 11,264 KB |
実行使用メモリ | 50,424 KB |
最終ジャッジ日時 | 2023-10-14 11:01:37 |
合計ジャッジ時間 | 5,785 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 79 ms
15,300 KB |
testcase_01 | AC | 80 ms
15,200 KB |
testcase_02 | AC | 79 ms
15,028 KB |
testcase_03 | AC | 79 ms
15,148 KB |
testcase_04 | WA | - |
testcase_05 | AC | 79 ms
15,108 KB |
testcase_06 | AC | 79 ms
15,076 KB |
testcase_07 | AC | 78 ms
15,032 KB |
testcase_08 | AC | 78 ms
15,252 KB |
testcase_09 | AC | 338 ms
48,080 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 330 ms
50,324 KB |
testcase_14 | WA | - |
testcase_15 | AC | 330 ms
50,424 KB |
testcase_16 | AC | 331 ms
50,056 KB |
testcase_17 | AC | 330 ms
48,116 KB |
testcase_18 | WA | - |
コンパイルメッセージ
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