제출 #1288712

#제출 시각아이디문제언어결과실행 시간메모리
1288712ozod_legendStove (JOI18_stove)Pypy 3
100 / 100
188 ms59124 KiB
n_k = input().split()
n = int(n_k[0])
k = int(n_k[1])

t = []
for i in range(n):
    a = int(input())
    t.append(a)

gaps = []
i = 0
while i < n - 1:
    gap = t[i + 1] - (t[i] + 1)
    gaps.append(gap)
    i = i + 1

gaps.sort()
gaps.reverse()

total = (t[n - 1] + 1) - t[0]

s = 0
i = 0
while i < k - 1 and i < len(gaps):
    s = s + gaps[i]
    i = i + 1

ans = total - s
print(ans)

컴파일 시 표준 출력 (stdout) 메시지

Compiling 'stove.py'...

=======
  adding: __main__.pyc (deflated 31%)

=======
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...