cswork / OA打开练习工作台

AmazonOA #354

Unique Pairs With Target Sum

估计简单可在线判题

考点(AI 标注)哈希计数双指针滑窗

Choose two different indices whose values sum to target. Order each pair internally by ascending value, output only distinct value pairs, and sort them in ascending numeric order of the first value and then the second value. Pairing a value with itself requires at least two occurrences, and duplicates in the input do not produce duplicate output.

输入格式

The first line contains n target and the second line contains n integers. On this site 0≤n≤200000, and the elements and target are all in −10^9..10^9.

输出格式

Output each distinct value pair as a,b on its own line (no parentheses, no spaces), in ascending numeric lexicographic order; if there is no answer, output a single line None.

样例 1

输入:

8 5
1 4 2 3 3 2 0 5

输出:

0,5
1,4
2,3

样例 2

输入:

4 10
1 2 3 4

输出:

None

样例 3

输入:

3 4
2 2 2

输出:

2,2

样例说明

The outputs of the three public examples are 0,5 / 1,4 / 2,3; None; and 2,2, checked by independent enumeration or direct simulation.