SHARE
TWEET

Untitled

a guest Oct 22nd, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. n = int(input())
  2. table = ['']
  3. for i in range(n-1):
  4.     table.append(input().split(' '))
  5. a = input()
  6. a, b = a.split(' ')
  7. a = int(a)
  8. b = int(b)
  9. cost = int(table[b][a])
  10. res = a
  11. for i in range(1, n):
  12.     if i != a and i != b:
  13.         if int(table[i][a]) + int(table[i][b]) < cost:
  14.             res = i
  15.             cost = int(table[i][a]) + int(table[i][b])
  16. print(res)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top