結果

問題 No.615 集合に分けよう
ユーザー urutomurutom
提出日時 2019-04-04 00:36:53
言語 Ruby
(3.3.0)
結果
AC  
実行時間 128 ms / 2,000 ms
コード長 203 bytes
コンパイル時間 530 ms
コンパイル使用メモリ 11,472 KB
実行使用メモリ 20,112 KB
最終ジャッジ日時 2023-08-25 03:37:12
合計ジャッジ時間 5,091 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,048 KB
testcase_01 AC 79 ms
15,244 KB
testcase_02 AC 82 ms
15,260 KB
testcase_03 AC 81 ms
15,120 KB
testcase_04 AC 81 ms
15,244 KB
testcase_05 AC 79 ms
15,124 KB
testcase_06 AC 80 ms
15,016 KB
testcase_07 AC 79 ms
15,304 KB
testcase_08 AC 81 ms
15,076 KB
testcase_09 AC 81 ms
15,072 KB
testcase_10 AC 81 ms
15,268 KB
testcase_11 AC 80 ms
15,100 KB
testcase_12 AC 80 ms
15,072 KB
testcase_13 AC 81 ms
15,008 KB
testcase_14 AC 82 ms
15,072 KB
testcase_15 AC 85 ms
15,712 KB
testcase_16 AC 127 ms
19,896 KB
testcase_17 AC 110 ms
19,268 KB
testcase_18 AC 127 ms
19,816 KB
testcase_19 AC 128 ms
19,832 KB
testcase_20 AC 127 ms
19,968 KB
testcase_21 AC 127 ms
20,112 KB
testcase_22 AC 127 ms
20,104 KB
testcase_23 AC 118 ms
19,636 KB
testcase_24 AC 125 ms
19,772 KB
testcase_25 AC 79 ms
15,120 KB
testcase_26 AC 79 ms
15,264 KB
testcase_27 AC 102 ms
18,808 KB
testcase_28 AC 104 ms
18,796 KB
testcase_29 AC 104 ms
19,052 KB
testcase_30 AC 117 ms
19,936 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n,k=gets.split.map(&:to_i)
if n==1
  puts 0
  exit
end
a=gets.split.map(&:to_i).sort
l=a.last-a.first
if k==1
  puts l
  exit
end
d=a.each_cons(2).map{|x,y|y-x}.sort.reverse
puts l-d.take(k-1).inject(:+)
0