3 条题解

  • 0
    @ 2026-3-11 15:28:28

    Python题解

    import sys
    input = lambda:sys.stdin.readline().strip()
    
    ans=0
    n,x = map(int,input().split())
    a = [0] + list(map(int,input().split()))
    
    i, j = 1, n
    while(i<j):
        if a[i] + a[j] == x:
            ans+=1
            i+=1
            continue
        if a[i] + a[j] < x:
            i+=1
            continue
        if a[i] + a[j] > x:
            j-=1
            continue
    print(ans)
    

    信息

    ID
    54
    时间
    1000ms
    内存
    256MiB
    难度
    2
    标签
    递交数
    172
    已通过
    66
    上传者