結果

問題 No.615 集合に分けよう
ユーザー buey_tbuey_t
提出日時 2023-03-31 10:18:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 167 ms / 2,000 ms
コード長 1,282 bytes
コンパイル時間 222 ms
コンパイル使用メモリ 81,752 KB
実行使用メモリ 97,700 KB
最終ジャッジ日時 2023-10-23 22:21:34
合計ジャッジ時間 6,244 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
84,380 KB
testcase_01 AC 122 ms
84,380 KB
testcase_02 AC 121 ms
84,376 KB
testcase_03 AC 122 ms
84,384 KB
testcase_04 AC 123 ms
84,372 KB
testcase_05 AC 123 ms
84,380 KB
testcase_06 AC 125 ms
84,380 KB
testcase_07 AC 125 ms
84,384 KB
testcase_08 AC 122 ms
84,376 KB
testcase_09 AC 125 ms
84,380 KB
testcase_10 AC 124 ms
84,384 KB
testcase_11 AC 128 ms
84,380 KB
testcase_12 AC 125 ms
84,376 KB
testcase_13 AC 124 ms
84,376 KB
testcase_14 AC 133 ms
88,252 KB
testcase_15 AC 142 ms
89,032 KB
testcase_16 AC 163 ms
97,680 KB
testcase_17 AC 164 ms
97,692 KB
testcase_18 AC 164 ms
97,696 KB
testcase_19 AC 164 ms
97,696 KB
testcase_20 AC 164 ms
97,692 KB
testcase_21 AC 167 ms
97,700 KB
testcase_22 AC 164 ms
97,680 KB
testcase_23 AC 152 ms
96,172 KB
testcase_24 AC 163 ms
97,336 KB
testcase_25 AC 123 ms
84,376 KB
testcase_26 AC 121 ms
84,376 KB
testcase_27 AC 144 ms
95,640 KB
testcase_28 AC 141 ms
95,640 KB
testcase_29 AC 151 ms
97,376 KB
testcase_30 AC 157 ms
97,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    from math import sqrt,sin,cos,tan,ceil,radians,floor,gcd,exp,log,log10,log2,factorial,fsum
    from heapq import heapify, heappop, heappush
    from bisect import bisect_left, bisect_right
    from copy import deepcopy
    import copy
    import random
    from collections import deque,Counter,defaultdict
    from itertools import permutations,combinations
    from decimal import Decimal,ROUND_HALF_UP
    #tmp = Decimal(mid).quantize(Decimal('0'), rounding=ROUND_HALF_UP)
    from functools import lru_cache, reduce
    #@lru_cache(maxsize=None)
    from operator import add,sub,mul,xor,and_,or_,itemgetter
    INF = 10**18
    mod1 = 10**9+7
    mod2 = 998244353
    
    #DecimalならPython
    #再帰ならPython!!!!!!!!!!!!!!!!!!!!!!!!!!
    
    
    '''
    
    
    
    '''
    
    N,K = map(int, input().split())
    A = list(map(int, input().split()))
    
    A.sort()
    
    ls = []
    for i in range(N-1):
        ls.append(A[i+1]-A[i])
    
    ls.sort()
    
    ans = 0
    for i in range(N-K):
        ans += ls[i]
    
    print(ans)
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
if __name__ == '__main__':
    main()
0