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

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

Revision ru1, by petr_qwerty, 2024-12-04 05:43:14

t=int(input()) cm=[] sk=[] ttm=[-11111111111111111] cr=[-10000000000000000] for i in range(t): a=int(input()) if(a>=0 and a%2==0): cm.append(a) elif(a>=0 and a%2!=0): sk.append(a) elif(a<=0 and a%2==0):

ttm.append(a)
elif(a<=0 and a%2!=0):
    cr.append(a)

if(len(cm)==0): cm.append(0) if(len(sk)==0): sk.append(0) print(max(sum(cm)-min(cm),sum(cm)+max(ttm))+max(sum(sk)-min(sk),sum(sk)+max(cr)))

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
ru1 Russian petr_qwerty 2024-12-04 05:43:14 504 Первая редакция (опубликовано)