結果

問題 No.615 集合に分けよう
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2023-11-15 22:57:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 322 bytes
コンパイル時間 321 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 77,716 KB
最終ジャッジ日時 2023-11-15 22:57:22
合計ジャッジ時間 3,371 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
55,604 KB
testcase_01 AC 46 ms
55,604 KB
testcase_02 AC 47 ms
55,604 KB
testcase_03 AC 44 ms
55,604 KB
testcase_04 AC 43 ms
55,604 KB
testcase_05 AC 43 ms
55,604 KB
testcase_06 AC 46 ms
55,604 KB
testcase_07 AC 43 ms
55,604 KB
testcase_08 AC 43 ms
55,604 KB
testcase_09 AC 43 ms
55,604 KB
testcase_10 AC 43 ms
55,604 KB
testcase_11 AC 48 ms
55,604 KB
testcase_12 AC 43 ms
55,604 KB
testcase_13 AC 42 ms
55,604 KB
testcase_14 AC 43 ms
57,708 KB
testcase_15 AC 49 ms
65,980 KB
testcase_16 AC 74 ms
77,716 KB
testcase_17 AC 73 ms
77,336 KB
testcase_18 AC 73 ms
77,332 KB
testcase_19 AC 74 ms
77,336 KB
testcase_20 AC 74 ms
77,336 KB
testcase_21 AC 75 ms
77,588 KB
testcase_22 AC 75 ms
77,716 KB
testcase_23 AC 61 ms
73,836 KB
testcase_24 AC 72 ms
76,936 KB
testcase_25 AC 42 ms
55,604 KB
testcase_26 AC 42 ms
55,604 KB
testcase_27 AC 53 ms
71,196 KB
testcase_28 AC 53 ms
71,196 KB
testcase_29 AC 57 ms
74,900 KB
testcase_30 AC 58 ms
77,080 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
from itertools import *
from functools import *
from heapq import *
import sys,math

N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
if N==1:
    print(0)
    exit()
B = [A[i+1]-A[i] for i in range(N-1)]
B.sort(reverse=True)
S = A[-1]-A[0]
print(S - sum(B[:K-1]))
    
0