Advertisement
Korotkodul

dem23.n27

Jun 17th, 2023
964
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.38 KB | None | 0 0
  1. a = []
  2. b = []
  3. f = open('27_A.txt')
  4. #f = open('tst.txt')
  5. n = int(f.readline())
  6. print(n)
  7. for i in range(n):
  8.     l = [int(i) for i in f.readline().split()]
  9.     #print(type(l))
  10.     a.append(l[0])
  11.     b.append(l[1])
  12. f.close()
  13. print(a)
  14. print(b)
  15.  
  16. mn = 10**40
  17. for k in range(n):
  18.     s = 0
  19.     for i in range(n):
  20.         s += abs(a[i] - a[k]) * b[i]
  21.     mn = min(s,mn)
  22. print(mn)
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement