AcWing 800. 数组元素的目标和-python3
原题链接
简单
作者:
Actor丶
,
2020-03-23 11:57:13
,
所有人可见
,
阅读 653
if __name__=="__main__":
n, m, x = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
j = m-1
for i in range(n):
while j>=0 and A[i]+B[j]>x:
j+=1
if A[i]+B[j]==x:
print(i, j)
break
if __name__=="__main__":
n, m, x = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
i = 0; j = m-1
while i<n and j>=0:
while A[i]+B[j]>x:
j-=1
while A[i]+B[j]<x:
i+=1
if A[i]+B[j]==x:
print(i, j)
break
-= 1第一个写错了