답안 #416820

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
416820 2021-06-03T02:39:21 Z zplizzi Stove (JOI18_stove) Python 3
0 / 100
16 ms 2856 KB
n, k = map(int, input().split())
times = []
for i in range(n):
    times.append(int(input()))
    
def solve(n, k, times):
    assert len(times) == n
    if n <= 1:
        return 0
    
    total_visit_duration = times[-1] + 1 - times[0]
        
    breaks = []
    for i in range(n-1):
        break_time = times[i+1] - (times[i] + 1)
        if break_time > 0:
            breaks.append(break_time)
            
    breaks = sorted(breaks, reverse=True)
    off_time = sum(breaks[:k-1])
    return total_visit_duration - off_time
  
print(solve(n, k, times))
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 2764 KB Output is correct
2 Correct 16 ms 2764 KB Output is correct
3 Correct 16 ms 2856 KB Output is correct
4 Correct 16 ms 2848 KB Output is correct
5 Correct 16 ms 2852 KB Output is correct
6 Correct 16 ms 2856 KB Output is correct
7 Correct 16 ms 2852 KB Output is correct
8 Correct 16 ms 2852 KB Output is correct
9 Incorrect 16 ms 2744 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 2764 KB Output is correct
2 Correct 16 ms 2764 KB Output is correct
3 Correct 16 ms 2856 KB Output is correct
4 Correct 16 ms 2848 KB Output is correct
5 Correct 16 ms 2852 KB Output is correct
6 Correct 16 ms 2856 KB Output is correct
7 Correct 16 ms 2852 KB Output is correct
8 Correct 16 ms 2852 KB Output is correct
9 Incorrect 16 ms 2744 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 2764 KB Output is correct
2 Correct 16 ms 2764 KB Output is correct
3 Correct 16 ms 2856 KB Output is correct
4 Correct 16 ms 2848 KB Output is correct
5 Correct 16 ms 2852 KB Output is correct
6 Correct 16 ms 2856 KB Output is correct
7 Correct 16 ms 2852 KB Output is correct
8 Correct 16 ms 2852 KB Output is correct
9 Incorrect 16 ms 2744 KB Output isn't correct