Advertisement
ss_

https://inf-ege.sdamgia.ru/test?theme=416

ss_
Apr 29th, 2021
1,248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. import numpy as np
  2.  
  3. # file_in = '27-demo.txt'  # 32
  4. file_in = '27-B_demo.txt'  # 399762080
  5. # file_in = '27-A_demo.txt'  # 127127
  6.  
  7. x = np.fromfile(file_in, sep=' ', dtype=np.int16)
  8. count = x[0]
  9. array = x[1:].reshape(count, 2)
  10. array = np.sort(array)
  11. sum_ = array[:, 1].sum()
  12.  
  13. array = np.array(sorted(array.tolist(), key=lambda x: x[1] - x[0])).reshape(count, 2)
  14.  
  15. for elem in array:
  16.     if (sum_ - elem[1] + elem[0]) % 3 != 0:
  17.         break
  18. print(sum_ - elem[1] + elem[0])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement