結果

問題 No.1248 Kth Sum
ユーザー soratasorata
提出日時 2020-10-24 16:08:14
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 374 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 11,196 KB
実行使用メモリ 30,160 KB
最終ジャッジ日時 2023-09-28 20:29:34
合計ジャッジ時間 6,730 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
19,512 KB
testcase_01 AC 83 ms
15,212 KB
testcase_02 AC 84 ms
15,176 KB
testcase_03 AC 85 ms
15,152 KB
testcase_04 AC 81 ms
14,968 KB
testcase_05 AC 84 ms
15,144 KB
testcase_06 AC 83 ms
15,212 KB
testcase_07 AC 81 ms
15,240 KB
testcase_08 AC 82 ms
15,104 KB
testcase_09 AC 83 ms
15,148 KB
testcase_10 AC 83 ms
15,124 KB
testcase_11 AC 82 ms
15,080 KB
testcase_12 AC 81 ms
15,168 KB
testcase_13 AC 159 ms
30,160 KB
testcase_14 AC 454 ms
30,088 KB
testcase_15 AC 160 ms
30,132 KB
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:3: warning: assigned but unused variable - i
Syntax OK

ソースコード

diff #

#!ruby
n,k,*a=gets(p).split.map(&:to_i)
i=0
d=n/k
r=[0,a[k-1]]

m = a[k-1]
2.upto(d) do |c|
  r=[0,a[k-1]]
  k.upto(a.size-1) do |i|
    c.downto(2) do |b|
      next if i<k*b-1 || r[b-1].nil?
      v = r[b-1]+a[i]
      if r[b].nil? || r[b] > v then
        r[b] = v
      end
    end
    r[1] = [r[1],a[i]].min if i<=(k-1)*c
  end
  m = [m,r[c]].min if r[c]
end      
p m
0