KiK0S

Untitled

Jun 18th, 2021
811
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. a = []
  2. n = 1000
  3.  
  4. for i in range(n):
  5.     a.append(int(input()))
  6.  
  7. max7_1 = 0
  8. max7_2 = 0
  9. max_1 = 0
  10. max_2 = 0
  11.  
  12. res = 0
  13.  
  14. for x in a:
  15.     if x % 160 != max7_1 % 160:
  16.         if x + max7_1 > res:
  17.             print(x, max7_1)
  18.         res = max(res, x + max7_1)
  19.     else:
  20.         if x + max7_2 > res:
  21.             print(x, max7_2)
  22.         res = max(res, x + max7_2)
  23.     if x % 7 == 0:
  24.         if x % 160 != max_1 % 160:
  25.             if x + max_1 > res:
  26.                 print(x, max_1)
  27.             res = max(res, x + max_1)
  28.         else:
  29.             if x + max_2 > res:
  30.                 print(x, max_2)
  31.             res = max(res, x + max_2)
  32.  
  33.     if x % 7 == 0:
  34.         if x > max7_1:
  35.             if x % 160 != max7_1 % 160:
  36.                 max7_2 = max7_1
  37.             max7_1 = x
  38.         elif x > max7_2:
  39.             if x % 160 != max7_1 % 160:
  40.                 max7_2 = x
  41.     else:
  42.         if x > max_1:
  43.             if x % 160 != max_1 % 160:
  44.                 max_2 = max_1
  45.             max_1 = x
  46.         elif x > max_2:
  47.             if x % 160 != max_1 % 160:
  48.                 max_2 = x
  49.  
  50. print(res)
  51.  
  52.  
  53. # max_mod = [0] * 120
  54. # res = 0
  55. # pair = (-1, -1)
  56. # for b in a:
  57. #   x = max_mod[(120 - (b % 120)) % 120]
  58. #   if (x + b) % 120 == 0 and (x + b) > res:
  59. #       pair = (x, b)
  60. #   max_mod[b % 120] = max(max_mod[b % 120], b)
  61.  
  62. # print(pair)
  63. # cnt = 0
  64. # cnt2 = 0
  65. # cnt31 = 0
  66. # cnt62 = 0
  67.  
  68. # for i in range(n):
  69. #   if a[i] % 62 == 0:
  70. #       cnt62 += 1
  71. #   elif a[i] % 31 == 0:
  72. #       cnt31 += 1
  73. #   elif a[i] % 2 == 0:
  74. #       cnt2 += 1
  75. #   else:
  76. #       cnt += 1
  77.  
  78. # # cnt = 20
  79. # # cnt2 = 10
  80. # # cnt31 = 7
  81. # # cnt62 = 3
  82.  
  83. # # 1, 2, 3
  84.  
  85.  
  86. # ans = 0
  87. # ans += cnt62 * cnt2
  88. # ans += cnt62 * cnt31
  89. # ans += cnt62 * cnt
  90. # ans += cnt31 * cnt2
  91. # ans += cnt62 * (cnt62 - 1) // 2
  92. # print(ans)
  93.  
  94. # max_ = 0
  95. # max7 = 0
  96.  
  97. # for i in range(n):
  98. #   if a[i] % 7 != 0:
  99. #       max_ = max(max_, a[i])
  100. #   else:
  101. #       max7 = max(max7, a[i])
  102.  
  103. # for i in range(n):
  104. #   if a[i] % 14 == 0 and a[i] > max14_1:
  105. #       max14_2 = max14_1
  106. #       max14_1 = a[i]
  107. #   elif a[i] % 14 == 0 and a[i] > max14_2:
  108. #       max14_2 = a[i]
  109. #   elif a[i] % 7 and a[i] > max7_:
  110. #       max7_ = a[i]
  111. #   elif a[i] % 2 and a[i] > max2_:
  112. #       a[i] = max2_
  113. #   elif a[i] > max_:
  114. #       max_ = a[i]
  115.    
  116. # res = max([max_ * max14_1, max2_ * max7_, max14_2 * max14_1])
  117. #
  118. #
  119. #
  120.  
  121. # print(max7 * max_)
RAW Paste Data