Submission #416821

# Submission time Handle Problem Language Result Execution time Memory
416821 2021-06-03T02:43:53 Z zplizzi Stove (JOI18_stove) Python 3
0 / 100
16 ms 2764 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 == 0:
        return 0
    if n == 1:
        assert k >= 1
        return 1
    
    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
  
solve(n, k, times)
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 2764 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 2764 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 2764 KB Output isn't correct
2 Halted 0 ms 0 KB -