結果

問題 No.78 クジ付きアイスバー
ユーザー wotsushiwotsushi
提出日時 2017-02-04 16:13:14
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 372 bytes
コンパイル時間 369 ms
コンパイル使用メモリ 11,276 KB
実行使用メモリ 15,920 KB
最終ジャッジ日時 2023-08-25 20:11:54
合計ジャッジ時間 5,985 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 93 ms
15,816 KB
testcase_02 AC 92 ms
15,884 KB
testcase_03 AC 93 ms
15,704 KB
testcase_04 AC 92 ms
15,648 KB
testcase_05 AC 90 ms
15,692 KB
testcase_06 AC 91 ms
15,644 KB
testcase_07 AC 93 ms
15,640 KB
testcase_08 AC 92 ms
15,676 KB
testcase_09 AC 92 ms
15,920 KB
testcase_10 AC 92 ms
15,680 KB
testcase_11 AC 95 ms
15,696 KB
testcase_12 AC 93 ms
15,656 KB
testcase_13 AC 92 ms
15,848 KB
testcase_14 AC 92 ms
15,560 KB
testcase_15 AC 91 ms
15,676 KB
testcase_16 AC 93 ms
15,824 KB
testcase_17 AC 93 ms
15,568 KB
testcase_18 AC 92 ms
15,744 KB
testcase_19 AC 93 ms
15,672 KB
testcase_20 AC 92 ms
15,904 KB
testcase_21 AC 92 ms
15,696 KB
testcase_22 AC 92 ms
15,868 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 92 ms
15,644 KB
testcase_26 AC 92 ms
15,684 KB
testcase_27 AC 93 ms
15,704 KB
testcase_28 AC 92 ms
15,692 KB
testcase_29 AC 94 ms
15,716 KB
testcase_30 AC 93 ms
15,564 KB
testcase_31 AC 94 ms
15,704 KB
testcase_32 AC 91 ms
15,692 KB
testcase_33 AC 96 ms
15,716 KB
testcase_34 AC 92 ms
15,628 KB
testcase_35 AC 93 ms
15,908 KB
testcase_36 AC 94 ms
15,652 KB
testcase_37 AC 92 ms
15,704 KB
testcase_38 AC 92 ms
15,800 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

require 'matrix'

N, K = gets.split.map(&:to_i)
S = gets.chomp
def f(s, i, m)
  if i == s.size
    Vector[0, m]
  elsif m > 0
    f(s, i + 1, m - 1 + s[i].to_i)
  else
    f(s, i + 1, s[i].to_i) + Vector[1, 0]
  end
end
a, b = f(S, 0, 0).to_a
ans = if K <= N or a <= b
        a
      else
        a + (K / N - 1) * (a - b) + f(S[0...(K % N)], 0, b)[0]
      end
puts ans
0