結果

問題 No.1313 N言っちゃダメゲーム (4)
ユーザー simansiman
提出日時 2022-06-09 19:25:57
言語 Ruby
(3.3.0)
結果
AC  
実行時間 170 ms / 2,000 ms
コード長 327 bytes
コンパイル時間 1,007 ms
コンパイル使用メモリ 11,880 KB
実行使用メモリ 18,160 KB
最終ジャッジ日時 2023-10-21 04:32:07
合計ジャッジ時間 7,617 ms
ジャッジサーバーID
(参考情報)
judge10 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
16,100 KB
testcase_01 AC 86 ms
16,100 KB
testcase_02 AC 87 ms
16,100 KB
testcase_03 AC 86 ms
16,100 KB
testcase_04 AC 86 ms
16,100 KB
testcase_05 AC 87 ms
16,100 KB
testcase_06 AC 88 ms
16,100 KB
testcase_07 AC 88 ms
16,100 KB
testcase_08 AC 87 ms
16,100 KB
testcase_09 AC 88 ms
16,100 KB
testcase_10 AC 89 ms
16,100 KB
testcase_11 AC 87 ms
16,100 KB
testcase_12 AC 88 ms
16,100 KB
testcase_13 AC 170 ms
18,160 KB
testcase_14 AC 165 ms
18,156 KB
testcase_15 AC 154 ms
18,160 KB
testcase_16 AC 152 ms
18,160 KB
testcase_17 AC 156 ms
18,160 KB
testcase_18 AC 132 ms
17,472 KB
testcase_19 AC 127 ms
17,376 KB
testcase_20 AC 96 ms
16,384 KB
testcase_21 AC 120 ms
17,088 KB
testcase_22 AC 106 ms
16,764 KB
testcase_23 AC 120 ms
17,228 KB
testcase_24 AC 93 ms
16,364 KB
testcase_25 AC 130 ms
17,460 KB
testcase_26 AC 89 ms
16,100 KB
testcase_27 AC 114 ms
17,012 KB
testcase_28 AC 154 ms
18,160 KB
testcase_29 AC 152 ms
18,160 KB
testcase_30 AC 151 ms
18,160 KB
testcase_31 AC 151 ms
18,160 KB
testcase_32 AC 155 ms
18,160 KB
testcase_33 AC 150 ms
18,160 KB
testcase_34 AC 153 ms
18,160 KB
testcase_35 AC 170 ms
18,160 KB
testcase_36 AC 160 ms
18,160 KB
testcase_37 AC 161 ms
18,160 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, K = gets.split.map(&:to_i)
S = gets.chomp

dp = Array.new(N + 1, -1)
dp[N] = 0
len = Float::INFINITY

(N - 1).downto(0) do |i|
  if i != 0 && S[i - 1] == 'x'
    len += 1
  else
    if len > K - 1
      dp[i] = 1
      len = 0
    else
      len += 1
    end
  end
end

idx = dp.index(1)

if idx
  puts idx
else
  puts 0
end
0