結果

問題 No.615 集合に分けよう
ユーザー yuppe19 😺yuppe19 😺
提出日時 2017-12-15 00:16:55
言語 Python2
(2.7.18)
結果
AC  
実行時間 94 ms / 2,000 ms
コード長 399 bytes
コンパイル時間 469 ms
コンパイル使用メモリ 6,640 KB
実行使用メモリ 13,644 KB
最終ジャッジ日時 2023-08-21 05:00:59
合計ジャッジ時間 3,151 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,052 KB
testcase_01 AC 12 ms
5,960 KB
testcase_02 AC 12 ms
5,996 KB
testcase_03 AC 12 ms
6,100 KB
testcase_04 AC 11 ms
6,052 KB
testcase_05 AC 12 ms
6,000 KB
testcase_06 AC 11 ms
5,996 KB
testcase_07 AC 11 ms
6,004 KB
testcase_08 AC 12 ms
5,992 KB
testcase_09 AC 12 ms
6,000 KB
testcase_10 AC 11 ms
5,996 KB
testcase_11 AC 11 ms
5,992 KB
testcase_12 AC 11 ms
5,980 KB
testcase_13 AC 12 ms
5,980 KB
testcase_14 AC 12 ms
6,004 KB
testcase_15 AC 26 ms
7,432 KB
testcase_16 AC 93 ms
13,380 KB
testcase_17 AC 94 ms
13,372 KB
testcase_18 AC 91 ms
13,432 KB
testcase_19 AC 92 ms
13,380 KB
testcase_20 AC 93 ms
13,644 KB
testcase_21 AC 94 ms
13,568 KB
testcase_22 AC 93 ms
13,564 KB
testcase_23 AC 60 ms
11,076 KB
testcase_24 AC 91 ms
13,468 KB
testcase_25 AC 11 ms
5,916 KB
testcase_26 AC 11 ms
5,972 KB
testcase_27 AC 46 ms
10,848 KB
testcase_28 AC 46 ms
10,848 KB
testcase_29 AC 54 ms
12,000 KB
testcase_30 AC 54 ms
11,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/python2
# -*- coding: utf-8 -*-
# †
from itertools import tee
# s -> (s0,s1), (s1,s2), (s2,s3), ...
def pairwise(iterable):
    a, b = tee(iterable)
    next(b, None)
    return zip(a, b)


N, K = map(int, raw_input().split())
a = map(int, raw_input().split())
a.sort()
difs = [q-p for p, q in pairwise(a)]
difs.sort()
res = a[-1] - a[0]
if K > 1:
    res -= sum(difs[-K+1:])
print res
0