Codeforces and Polygon may be unavailable from December 6, 19:00 (UTC) to December 6, 21:00 (UTC) due to technical maintenance. ×

МЭ информатика D9

Revision ru1, by petr_qwerty, 2024-12-03 17:56:15

a=int(input()) b=int(input()) nk=0 k=0 critical=0 seconds=0 cm=[] sk=[] for i in range(a): c,d=map(int,input().split()) cm.append(c) sk.append(d) while(sum(cm)>0): seconds+=max(0,cm[k]-critical) cm[k]=0 critical=sk[k] k+=b if(k>len(cm)-1): nk+=1 k=nk critical=0 print(seconds)

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
ru1 Russian petr_qwerty 2024-12-03 17:56:15 380 Первая редакция (опубликовано)