#45435: easy


0801elmer666@gmail.com (薛冠志)

學校 : 國立霧峰高級農工職業學校
編號 : 273218
來源 : [111.83.153.175]
最後登入時間 :
2025-04-22 12:40:30
q181. 1. 等紅綠燈 -- 2025年1月APCS | From: [42.79.194.62] | 發表日期 : 2025-03-04 12:48

a, b = map(int,input().split())
num = int(input())
time = list(map(int,input().split()))
total = 0
for i in range(num):
  total_num = 0
  one = a + b
  plus = time[i] % one
  green = plus - a
  if green < 0:
    total_num = 0
  elif green == 0:
    total_num = b
  else:
    total_num = b - green
  total += total_num
print(total)
 
ZeroJudge Forum