Created
October 31, 2021 11:30
-
-
Save mivvka/64f9e24408312432a8b691c4d9c132ef to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# P2. Сумма: ближайшая | |
import numpy as np | |
n = int(input()) | |
listA = np.array([int(x) for x in input().split()], int) | |
listB = np.array([int(x) for x in input().split()], int) | |
listA.sort() | |
listB.sort() | |
lenA = len(listA) | |
lenB = len(listB) | |
A = listA[0] | |
B = listB[0] | |
smm = sum([A, B]) | |
matrixS = np.array([abs((x + y) - n) for x in listA for y in listB]).reshape(lenA, lenB) | |
indices = np.where(matrixS == matrixS.min()) | |
print(listA[indices[0][0]], listB[indices[1][0]]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment