Advertisement
jootiee

Untitled

Apr 18th, 2022
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. import numpy as np
  2.  
  3.  
  4. file = ""
  5.  
  6. k = 10
  7.  
  8. with open(file, "r") as f:
  9. data = list(map(int, f.readlines()))
  10. sums = np.zeros(k, dtype=np.int64)
  11.  
  12. sums_first = [0] + [None] * (k - 1)
  13. sums_last = [0] + [None] * (k - 1)
  14.  
  15. sum_current = 0
  16.  
  17. count_even = 0
  18.  
  19. for elem in data:
  20. sum_current += elem
  21. if elem % 2 == 0:
  22. count_even += 1
  23.  
  24. if count_even < k and sums_first[count_even] is None:
  25. sums_first[count_even] = sum_current
  26.  
  27. sums_last[count_even % k] = sum_current
  28.  
  29. if count_even == 890381:
  30. print(sum_current - elem)
  31.  
  32. print(np.max(np.array(sums_last) - np.array(sums_first)))
  33.  
  34. # 4779554 981035456
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement