結果

問題 No.615 集合に分けよう
ユーザー mitsuomitsuo
提出日時 2017-12-31 00:22:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 76 ms / 2,000 ms
コード長 304 bytes
コンパイル時間 99 ms
コンパイル使用メモリ 10,592 KB
実行使用メモリ 13,712 KB
最終ジャッジ日時 2023-08-23 11:16:07
合計ジャッジ時間 2,476 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,856 KB
testcase_01 AC 16 ms
7,948 KB
testcase_02 AC 15 ms
7,836 KB
testcase_03 AC 16 ms
7,852 KB
testcase_04 AC 16 ms
7,952 KB
testcase_05 AC 16 ms
7,948 KB
testcase_06 AC 15 ms
7,824 KB
testcase_07 AC 15 ms
7,856 KB
testcase_08 AC 15 ms
7,856 KB
testcase_09 AC 16 ms
7,812 KB
testcase_10 AC 16 ms
7,908 KB
testcase_11 AC 16 ms
7,836 KB
testcase_12 AC 15 ms
7,912 KB
testcase_13 AC 16 ms
7,788 KB
testcase_14 AC 16 ms
8,244 KB
testcase_15 AC 26 ms
9,364 KB
testcase_16 AC 75 ms
13,516 KB
testcase_17 AC 76 ms
13,536 KB
testcase_18 AC 76 ms
13,500 KB
testcase_19 AC 76 ms
13,496 KB
testcase_20 AC 76 ms
13,500 KB
testcase_21 AC 76 ms
13,500 KB
testcase_22 AC 76 ms
13,500 KB
testcase_23 AC 45 ms
12,060 KB
testcase_24 AC 62 ms
13,712 KB
testcase_25 AC 15 ms
7,912 KB
testcase_26 AC 16 ms
7,852 KB
testcase_27 AC 34 ms
9,424 KB
testcase_28 AC 33 ms
9,428 KB
testcase_29 AC 42 ms
13,512 KB
testcase_30 AC 42 ms
13,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve_new(l, k, d):
    d = [int(n) for n in d]
    d.sort(key=int)
    diff = []
    for i in range(len(d) - 1):
        diff.append(d[i+1] - d[i])
    return sum(sorted(diff)[:len(d) - k])

if __name__ == '__main__':
    l, k = map(int, input().split())
    print(solve_new(l, k, input().split()))
0