CPE OJ - B001 - Pair Sum Count
CPE OJ - B001 - Pair Sum Count
來源代碼:cpeoj
前往提交 ↓
Given an integer array nums of length n and a target value k, count the number of index pairs (i, j) such that i< j and nums[i]+ nums[j] == k .
輸入說明
First line: two integers n and k Second line: n integers nums[0..n-1]
2≤n≤2×10^5
−10^9≤nums[i],k≤10^9
輸出說明
A single integer: the number of valid pairs. Ends with a newline
輸入輸出範例
範例 1
範例輸入
5 6 1 5 3 3 2
範例輸出
2
登入後即可撰寫程式、測試範例及提交解答。
登入