Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #coding: utf-8
- n = int(input())
- mx1 = mx2 = mx01 = mx02 = 0
- for i in range(n):
- x = int(input())
- if x % 3 == 1 and x > mx1:
- mx1 = x
- if x % 3 == 2 and x > mx2:
- mx2 = x
- if x % 3 == 0:
- if mx01 < x < mx02:
- mx01 = x
- if x > mx02:
- mx01, mx02 = mx02, x
- # True, если можно взять mx1 + mx2, иначе False
- f1 = mx1 != 0 and mx2 != 0
- # True, если можно взять mx01 + mx02, иначе False
- f2 = mx01 != 0 and mx02 != 0
- if f1 == True and f2 == True:
- R = max(mx1 + mx2, mx01 + mx02)
- elif f1 == True and f2 == False:
- R = mx1 + mx2
- elif f1 == False and f2 == True:
- R = mx01 + mx02
- elif f1 == False and f2 == False:
- R = 1
- x = int(input())
- print('Вычисленное контрольное значение:', R)
- if x == R:
- print('Контроль пройден')
- else:
- print('Контроль не пройден')
Add Comment
Please, Sign In to add comment