結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
15,720 KB
testcase_01 AC 90 ms
15,700 KB
testcase_02 AC 93 ms
15,900 KB
testcase_03 AC 95 ms
15,736 KB
testcase_04 AC 95 ms
15,880 KB
testcase_05 AC 94 ms
15,636 KB
testcase_06 AC 94 ms
15,692 KB
testcase_07 AC 93 ms
15,676 KB
testcase_08 AC 93 ms
15,628 KB
testcase_09 AC 94 ms
15,728 KB
testcase_10 AC 93 ms
15,728 KB
testcase_11 AC 95 ms
15,620 KB
testcase_12 AC 94 ms
15,884 KB
testcase_13 AC 93 ms
15,904 KB
testcase_14 AC 93 ms
15,840 KB
testcase_15 AC 92 ms
15,716 KB
testcase_16 AC 93 ms
15,876 KB
testcase_17 AC 91 ms
15,860 KB
testcase_18 AC 92 ms
15,800 KB
testcase_19 AC 92 ms
15,684 KB
testcase_20 AC 92 ms
15,940 KB
testcase_21 AC 93 ms
15,704 KB
testcase_22 AC 93 ms
15,636 KB
testcase_23 AC 92 ms
15,648 KB
testcase_24 AC 91 ms
15,912 KB
testcase_25 AC 91 ms
15,716 KB
testcase_26 WA -
testcase_27 AC 93 ms
15,740 KB
testcase_28 AC 93 ms
15,588 KB
testcase_29 AC 93 ms
15,616 KB
testcase_30 AC 93 ms
15,860 KB
testcase_31 AC 92 ms
15,848 KB
testcase_32 AC 93 ms
15,588 KB
testcase_33 AC 93 ms
15,588 KB
testcase_34 AC 92 ms
15,804 KB
testcase_35 AC 93 ms
15,848 KB
testcase_36 AC 92 ms
15,820 KB
testcase_37 AC 92 ms
15,800 KB
testcase_38 AC 94 ms
15,832 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
        f(S[0...(K % N)], 0, 0)[0]
      else
        a + (K / N - 1) * [a - b, 0].max + f(S[0...(K % N)], 0, b)[0]
      end
puts ans
0