結果

問題 No.615 集合に分けよう
ユーザー tamatotamato
提出日時 2020-05-15 21:08:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 74 ms / 2,000 ms
コード長 389 bytes
コンパイル時間 686 ms
コンパイル使用メモリ 81,824 KB
実行使用メモリ 77,064 KB
最終ジャッジ日時 2023-10-19 11:53:28
合計ジャッジ時間 4,470 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,628 KB
testcase_01 AC 38 ms
53,628 KB
testcase_02 AC 37 ms
53,628 KB
testcase_03 AC 37 ms
53,628 KB
testcase_04 AC 37 ms
53,628 KB
testcase_05 AC 37 ms
53,628 KB
testcase_06 AC 38 ms
53,628 KB
testcase_07 AC 37 ms
53,628 KB
testcase_08 AC 38 ms
53,628 KB
testcase_09 AC 37 ms
53,628 KB
testcase_10 AC 38 ms
53,628 KB
testcase_11 AC 38 ms
53,628 KB
testcase_12 AC 38 ms
53,628 KB
testcase_13 AC 38 ms
53,628 KB
testcase_14 AC 38 ms
53,628 KB
testcase_15 AC 48 ms
61,936 KB
testcase_16 AC 72 ms
77,056 KB
testcase_17 AC 70 ms
76,848 KB
testcase_18 AC 71 ms
76,848 KB
testcase_19 AC 71 ms
76,852 KB
testcase_20 AC 72 ms
76,860 KB
testcase_21 AC 73 ms
77,064 KB
testcase_22 AC 74 ms
77,060 KB
testcase_23 AC 58 ms
73,776 KB
testcase_24 AC 71 ms
76,596 KB
testcase_25 AC 39 ms
53,628 KB
testcase_26 AC 38 ms
53,628 KB
testcase_27 AC 51 ms
71,388 KB
testcase_28 AC 52 ms
71,388 KB
testcase_29 AC 55 ms
74,460 KB
testcase_30 AC 58 ms
76,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()

    D = []
    for i in range(N-1):
        D.append(A[i+1] - A[i])
    D.sort()
    ans = A[-1] - A[0]
    for _ in range(K-1):
        ans -= D.pop()
    print(ans)


if __name__ == '__main__':
    main()
0