Submission #542777

#TimeUsernameProblemLanguageResultExecution timeMemory
542777QuantumK9Stove (JOI18_stove)Cpython 3
100 / 100
219 ms12248 KiB
n, k = [ int(x) for x in input().split() ] a = [] for i in range(n): a.append( int(input()) ) a.sort() t = a[n-1]+1-a[0] #print(t) diff = [] for i in range(0,n-1): diff.append( a[i+1] - (a[i]+1) ) diff.sort() diff.reverse() #print( diff ) for i in range( min( n-1, k-1 ) ): t -= diff[i] print( t )
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...