Shiyan12

Задача 27.61

Dec 25th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.95 KB | None | 0 0
  1. #coding: utf-8
  2.  
  3. n = int(input())
  4. mx1 = mx2 = mx01 = mx02 = 0
  5. for i in range(n):
  6.     x = int(input())
  7.     if x % 3 == 1 and x > mx1:
  8.         mx1 = x
  9.     if x % 3 == 2 and x > mx2:
  10.         mx2 = x
  11.     if x % 3 == 0:
  12.         if mx01 < x < mx02:
  13.             mx01 = x
  14.         if x > mx02:
  15.             mx01, mx02 = mx02, x
  16.  
  17. # True, если можно взять mx1 + mx2, иначе False
  18. f1 = mx1 != 0 and mx2 != 0
  19.  
  20. # True, если можно взять mx01 + mx02, иначе False
  21. f2 = mx01 != 0 and mx02 != 0
  22.  
  23. if f1 == True and f2 == True:
  24.     R = max(mx1 + mx2, mx01 + mx02)
  25. elif f1 == True and f2 == False:
  26.     R = mx1 + mx2
  27. elif f1 == False and f2 == True:
  28.     R = mx01 + mx02
  29. elif f1 == False and f2 == False:
  30.     R = 1
  31.    
  32. x = int(input())
  33. print('Вычисленное контрольное значение:', R)
  34. if x == R:
  35.     print('Контроль пройден')
  36. else:
  37.     print('Контроль не пройден')
Add Comment
Please, Sign In to add comment