Advertisement
stupid_pro

Untitled

Jun 14th, 2023
713
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.90 KB | None | 0 0
  1. # with open('26_813.txt') as file:
  2. #     s, n = map(int, file.readline().split()) #свободное место на диске и число пользователей
  3. #     a = [int(x) for x in file]
  4. # a.sort(reverse=True)
  5. # summa = 0
  6. # k = 0
  7. # last_one = 0
  8. # for i in range(len(a) // 2):
  9. #     if summa + a[i] <= s:
  10. #         summa += a[i]
  11. #         k += 1
  12. #         last_one = a[i]
  13. #         a[i] = 0
  14. #     if summa + a[len(a) - i - 1] <= s:
  15. #         summa += a[len(a) - i - 1]
  16. #         k += 1
  17. #         last_one = a[len(a) - i - 1]
  18. #         a[i] = 0
  19. # a = [int(x) for x in a if x != 0]
  20. # print(a)
  21. # print(last_one, summa, k)
  22.  
  23. # with open('26_838.txt') as file:
  24. #     n = int(file.readline())
  25. #     a = [int(x) for x in file]
  26. #
  27. # a.sort()
  28. # first = [max(a)]
  29. # second = []
  30. # a.pop(len(a) - 1)
  31. # # print(a)
  32. #
  33. # for t in range(2053):
  34. #     i = 0
  35. #     while sum(second) <= sum(first):
  36. #         second.append(a[i])
  37. #         a[i] = 0
  38. #         i += 1
  39. #     a = [int(x) for x in a if x != 0]
  40. #     first.append(max(a))
  41. #     a.pop(len(a) - 1)
  42. #
  43. # print(a)
  44. # print(first)
  45. # print(sum(first))
  46. # print(second)
  47. # print(sum(second))
  48. # print(len(first), len(second) + 1)
  49.  
  50. # with open('26_936.txt') as file:
  51. #     n, s = map(int, file.readline().split())
  52. #     a = [int(c) for c in file.readlines()]
  53. #
  54. # a.sort(reverse=True)
  55. # summa = 0
  56. # k = 0
  57. # last = 0
  58. #
  59. #
  60. # while len(a) > 0:
  61. #     for i in range(len(a)):
  62. #         if summa + a[i] <= s:
  63. #             summa += a[i]
  64. #             a[i] = 0
  65. #     a = [int(c) for c in a if c != 0]
  66. #     print(len(a))
  67. #     k += 1
  68. #     last = summa
  69. #     summa = 0
  70. # print(k, last)
  71.  
  72. # with open('26_1079.txt') as file:
  73. #     n = file.readline()
  74. #     a = [int(c) for c in file]
  75. #
  76. # a.sort()
  77. # print(a)
  78. # ans = []
  79. #
  80. # for i in range(len(a) - 1):
  81. #     for j in range(i + 1, len(a)):
  82. #         if (a[i] + a[j]) % 2 == 0:
  83. #             mid = (a[i] + a[j]) // 2
  84. #             if a[2499] < mid < a[3750]:
  85. #                 ans.append(mid)
  86. # print(len(ans), min(ans))
  87.  
  88. # with open('26_1257.txt') as file:
  89. #     n = int(file.readline())
  90. #     a = [int(c) for c in file]
  91. #
  92. # a.sort()
  93. # d = set(a)
  94. # ans = []
  95. #
  96. # for i in range(len(a) - 1):
  97. #     for j in range(i + 1, len(a)):
  98. #         summa = a[i] + a[j]
  99. #         if summa % 2 == 1 and summa in d:
  100. #             ans.append(summa)
  101. # print(len(ans), max(ans))\
  102.  
  103. # with open('26_2652.txt') as file:
  104. #     n = int(file.readline())
  105. #     a = [int(c) for c in file]
  106. #
  107. # d = set(a)
  108. # max_ans = -10 ** 10
  109. #
  110. # for i in d:
  111. #     max_ans = max(max_ans, a.count(i))
  112. #
  113. # print(len(d), max_ans)
  114.  
  115. # with open('26_2480.txt') as file:
  116. #     n = int(file.readline())
  117. #     d = [c for c in file]
  118. #
  119. # a = [0] * 2_000_001
  120. #
  121. # for i in d:
  122. #     x, y = map(int, i.split())
  123. #     a[x] += 1
  124. #     a[y] -= 1
  125. #
  126. # count, length = 0, 0
  127. # k = 0
  128. # st, end = -1, 0
  129. #
  130. # for i in range(len(a)):
  131. #     k0 = k
  132. #     k += a[i]
  133. #     if k > 0 and st == -1:
  134. #         st = i
  135. #     if k == 0 and k0 > 0:
  136. #         end = i
  137. #         length += end - st
  138. #         count += 1
  139. #         st, end = -1, 0
  140. #
  141. # print(count, length)
  142.  
  143. # with open('26_2650.txt') as file:
  144. #     l, m, n = map(int, file.readline().split())
  145. #     d = [c for c in file]
  146. #
  147. # a = [0] * (l + 1)
  148. #
  149. # a[0] += 1
  150. #
  151. # for i in range(len(d)):
  152. #     x, time = map(int, d[i].split())
  153. #     a[x] -= 1
  154. #     a[x + time] += 1
  155. # a[l] -= 1
  156. #
  157. # # print(a.count(1), a.count(-1))
  158. #
  159. # ans = []
  160. # count = 0
  161. # k = 0
  162. # st, end = -1, 0
  163. #
  164. # for i in range(len(a)):
  165. #     k0 = k
  166. #     k += a[i]
  167. #     if k > 0 and st == -1:
  168. #         st = i
  169. #     if k == 0 and k0 > 0:
  170. #         end = i
  171. #         length = end - st
  172. #         print(length)
  173. #         if length >= m:
  174. #             ans.append(length)
  175. #         st, end = -1, 0
  176. #
  177. # print(len(ans), max(ans))
  178.  
  179. # mx = -10 ** 10
  180. # my = -10 ** 10
  181. # counter = 0
  182. # a = [[0] * 9 for c in range(2000)]
  183. # with open('26_2651.txt') as file:
  184. #     n = int(file.readline())
  185. #     for line in file:
  186. #         year, tp = map(int, line.split())
  187. #         a[year][tp] += 1
  188. #
  189. # for i in range(1961, 1992):
  190. #     k = 0
  191. #     for j in range(1, 9):
  192. #         if a[i][j] == 0:
  193. #             k += 1
  194. #     counter += k
  195. #     if k >= mx:
  196. #         mx = k
  197. #         my = i
  198. #
  199. # print(counter, my)
  200.  
  201. # for i in range(1961, 1992):
  202. #     print(a[i])
  203.  
  204. with open('26_2653.txt') as file:
  205.     n = file.readline()
  206.     a = [int(c) for c in file]
  207.  
  208. a.sort()
  209. ans = [a[0]]
  210. print(a)
  211. # for i in range(1, len(a)):
  212. #     ans.append(a[i])
  213. #     for elem in range(len(ans)):
  214. #         ans.append(a[i] + ans[elem])
  215.  
  216. d = set()
  217. d.add(a[0])
  218. for i in range(1, len(a)):
  219.     d.add(a[i])
  220.     adding = set()
  221.     for elem in d:
  222.         adding.add(a[i] + elem)
  223.     d = d.union(adding)
  224. ans = sorted(c for c in d)
  225. count = 0
  226. for i in range(len(ans) - 1):
  227.     count += (ans[i + 1] - ans[i] - 1)
  228. print(count)
  229. print(ans[200:])
  230.  
  231.  
Tags: 26_kege
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement