結果

問題 No.615 集合に分けよう
ユーザー FromBooskaFromBooska
提出日時 2023-02-25 21:23:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 110 ms / 2,000 ms
コード長 333 bytes
コンパイル時間 768 ms
コンパイル使用メモリ 86,936 KB
実行使用メモリ 86,172 KB
最終ジャッジ日時 2023-10-11 17:27:23
合計ジャッジ時間 5,309 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,276 KB
testcase_01 AC 76 ms
71,284 KB
testcase_02 AC 76 ms
71,252 KB
testcase_03 AC 75 ms
71,396 KB
testcase_04 AC 75 ms
71,552 KB
testcase_05 AC 74 ms
71,368 KB
testcase_06 AC 75 ms
71,224 KB
testcase_07 AC 75 ms
71,048 KB
testcase_08 AC 75 ms
71,232 KB
testcase_09 AC 75 ms
71,496 KB
testcase_10 AC 74 ms
71,428 KB
testcase_11 AC 74 ms
71,212 KB
testcase_12 AC 75 ms
71,196 KB
testcase_13 AC 76 ms
71,556 KB
testcase_14 AC 76 ms
71,472 KB
testcase_15 AC 84 ms
76,392 KB
testcase_16 AC 107 ms
85,400 KB
testcase_17 AC 108 ms
86,000 KB
testcase_18 AC 110 ms
85,936 KB
testcase_19 AC 109 ms
86,004 KB
testcase_20 AC 110 ms
86,172 KB
testcase_21 AC 109 ms
85,748 KB
testcase_22 AC 108 ms
85,396 KB
testcase_23 AC 96 ms
84,500 KB
testcase_24 AC 108 ms
85,780 KB
testcase_25 AC 75 ms
71,164 KB
testcase_26 AC 77 ms
71,296 KB
testcase_27 AC 89 ms
84,092 KB
testcase_28 AC 89 ms
84,020 KB
testcase_29 AC 94 ms
85,608 KB
testcase_30 AC 92 ms
85,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 数の差の問題
# 数の差をリストアウト、ソート
# その最大の差K-1個をスキップできる

N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
diff = []
for i in range(N-1):
    diff.append(A[i+1]-A[i])
diff.sort(reverse = True)
    
#print(diff)

ans = sum(diff[K-1:])
print(ans)
0