結果

問題 No.615 集合に分けよう
ユーザー motimoti
提出日時 2018-05-30 02:05:45
言語 Perl
(5.38.2)
結果
TLE  
実行時間 -
コード長 415 bytes
コンパイル時間 410 ms
コンパイル使用メモリ 11,396 KB
実行使用メモリ 23,992 KB
最終ジャッジ日時 2023-09-12 20:33:49
合計ジャッジ時間 8,130 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
11,228 KB
testcase_01 AC 40 ms
11,304 KB
testcase_02 AC 40 ms
11,340 KB
testcase_03 AC 40 ms
11,300 KB
testcase_04 AC 41 ms
11,076 KB
testcase_05 AC 41 ms
11,136 KB
testcase_06 AC 42 ms
11,236 KB
testcase_07 AC 47 ms
11,188 KB
testcase_08 AC 47 ms
11,264 KB
testcase_09 AC 48 ms
11,044 KB
testcase_10 AC 48 ms
11,372 KB
testcase_11 AC 47 ms
11,248 KB
testcase_12 AC 44 ms
11,156 KB
testcase_13 AC 75 ms
11,172 KB
testcase_14 AC 111 ms
11,292 KB
testcase_15 AC 746 ms
12,876 KB
testcase_16 TLE -
testcase_17 TLE -
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 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

#!/usr/bin/env perl

use strict;
use warnings;
use bigint;

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