結果

問題 No.615 集合に分けよう
ユーザー motimoti
提出日時 2018-05-30 02:06:09
言語 Perl
(5.38.2)
結果
AC  
実行時間 74 ms / 2,000 ms
コード長 376 bytes
コンパイル時間 36 ms
コンパイル使用メモリ 5,216 KB
実行使用メモリ 12,928 KB
最終ジャッジ日時 2023-09-12 20:33:28
合計ジャッジ時間 2,643 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,660 KB
testcase_01 AC 3 ms
4,640 KB
testcase_02 AC 3 ms
4,632 KB
testcase_03 AC 2 ms
4,516 KB
testcase_04 AC 2 ms
4,644 KB
testcase_05 AC 2 ms
4,516 KB
testcase_06 AC 3 ms
4,588 KB
testcase_07 AC 2 ms
4,468 KB
testcase_08 AC 3 ms
4,612 KB
testcase_09 AC 3 ms
4,596 KB
testcase_10 AC 3 ms
4,560 KB
testcase_11 AC 3 ms
4,584 KB
testcase_12 AC 2 ms
4,596 KB
testcase_13 AC 3 ms
4,564 KB
testcase_14 AC 3 ms
4,804 KB
testcase_15 AC 14 ms
6,284 KB
testcase_16 AC 65 ms
12,924 KB
testcase_17 AC 68 ms
12,844 KB
testcase_18 AC 74 ms
12,876 KB
testcase_19 AC 67 ms
12,852 KB
testcase_20 AC 69 ms
12,928 KB
testcase_21 AC 68 ms
12,836 KB
testcase_22 AC 66 ms
12,928 KB
testcase_23 AC 48 ms
12,388 KB
testcase_24 AC 67 ms
12,684 KB
testcase_25 AC 3 ms
4,608 KB
testcase_26 AC 3 ms
4,608 KB
testcase_27 AC 33 ms
12,092 KB
testcase_28 AC 34 ms
12,196 KB
testcase_29 AC 37 ms
12,640 KB
testcase_30 AC 36 ms
12,648 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

#!/usr/bin/env perl

my ($n, $k) = split / /, <>; chomp $k;
my @array = split / /, <>;
chomp $array[$n - 1];

@array = sort { $a <=> $b } @array;
my @narray;
for (my $i = 0; $i < $n - 1; $i++) {
  push @narray, $array[$i + 1] - $array[$i];
}

@narray = sort { $a <=> $b } @narray;
my $res = 0;
for (my $i = 0; $i < $n - $k; $i++) {
  $res += $narray[$i];
}

print $res, "\n";
0