結果

問題 No.1313 N言っちゃダメゲーム (4)
ユーザー TANIGUCHI KousukeTANIGUCHI Kousuke
提出日時 2020-12-21 22:06:13
言語 Ruby
(3.3.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 387 bytes
コンパイル時間 282 ms
コンパイル使用メモリ 11,800 KB
実行使用メモリ 18,292 KB
最終ジャッジ日時 2023-10-21 11:52:54
合計ジャッジ時間 40,454 ms
ジャッジサーバーID
(参考情報)
judge14 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
16,028 KB
testcase_01 AC 90 ms
16,028 KB
testcase_02 AC 90 ms
16,028 KB
testcase_03 AC 90 ms
16,028 KB
testcase_04 AC 92 ms
16,028 KB
testcase_05 AC 91 ms
16,028 KB
testcase_06 AC 89 ms
16,028 KB
testcase_07 AC 90 ms
16,028 KB
testcase_08 AC 89 ms
16,028 KB
testcase_09 AC 92 ms
16,028 KB
testcase_10 AC 91 ms
16,028 KB
testcase_11 AC 92 ms
16,028 KB
testcase_12 AC 91 ms
16,028 KB
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 AC 963 ms
17,524 KB
testcase_19 AC 846 ms
17,420 KB
testcase_20 AC 116 ms
16,328 KB
testcase_21 AC 523 ms
17,104 KB
testcase_22 AC 279 ms
16,744 KB
testcase_23 AC 663 ms
17,256 KB
testcase_24 AC 111 ms
16,308 KB
testcase_25 AC 950 ms
17,516 KB
testcase_26 AC 93 ms
16,024 KB
testcase_27 AC 454 ms
17,020 KB
testcase_28 TLE -
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
testcase_33 TLE -
testcase_34 TLE -
testcase_35 TLE -
testcase_36 TLE -
testcase_37 TLE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def min(a,b); a < b ? a : b; end
  
N, K = gets.split.map(&:to_i)
S = "o#{gets.chomp}x"
dp = Array.new(N + 1)
dp[N] = 0

(1 .. N).each do |i|
  j = N - i
  l = j + 1
  r = min(l + K, N)
  if S[j] == 'x' || dp[l] - dp[r] < r - l
    dp[j] = dp[j + 1] + 1
  else
    dp[j] = dp[j + 1]
  end
end
if dp[1] - dp[K + 1] < K
  puts (1 .. K).select{|i| dp[i] - dp[i + 1] == 0 }
else
  puts 0
end
0