Submission #416819

# Submission time Handle Problem Language Result Execution time Memory
416819 2021-06-03T02:38:15 Z zplizzi Stove (JOI18_stove) Python 3
0 / 100
20 ms 2764 KB
n, k = map(int, input().split())
times = []
for i in range(n):
    l.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))
# Verdict Execution time Memory Grader output
1 Runtime error 20 ms 2764 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 20 ms 2764 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 20 ms 2764 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -