Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
86969 sh25_shenpy 汽车加油问题 Python3 无测评数据 0 MS 0 KB 516 2026-04-10 14:54:50

Tests(0/0):


n, k = map(int, input().split()) dist = list(map(int, input().split())) # 检查是否有无法通过的路段 for d in dist: if d > n: print("No Solution") exit() current_fuel = n refuel_count = 0 for i in range(k + 1): # 共 k+1 段路 if current_fuel >= dist[i]: current_fuel -= dist[i] else: # 在当前起点(第i个加油站)加油 refuel_count += 1 current_fuel = n - dist[i] # 加满后跑这段路 print(refuel_count)