4 条题解
题解与来源题共享。已有题解默认通过;新增或编辑后需由来源域管理员审核。待审核、驳回题解仅作者和审核管理员可见。来源域:system
-
0
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
- 难度
- 普及−
- 标签
- 递交数
- 387
- 已通过
- 149
- 上传者