LCC '24 Contest 2 S3 - Partners

View as PDF

Submit solution


Points: 7 (partial)
Time limit: 3.5s
Memory limit: 256M

Author:
Problem types

Welcome to your third game.

Looking around the room, there are 2N (1 \le N \le 10^5) players left, including yourself - player 1.

The objective in this game to find your matching partner.

Each person's cyan jersey is numbered with a_i (0 \le a_i \le 10^9). There doesn't seem to be any duplicate numbers.

The sum of the numbers on you and your partner's jerseys should be the same for each pair.

And if you don't find your partner soon, you'll be eliminated.

Input Specifications

On the first line, an integer N.

On the second line, 2N space-separated integers, a_i.

Output Specifications

On a single line, print the jersey number of your partner.

It is guaranteed that there exists a unique solution.

Constraints

Subtask 1 [50%]

1 \le N \le 1000

1 \le a_i \le 10^6

Subtask 2 [50%]

1 \le N \le 10^5

1 \le a_i \le 10^9

Sample Input 1

3
1 4 8 7 11 5

Sample Output 1

11

Sample Explanation 1

The pairs should be 1 11, 4 8, 5 7, where each pair adds to 12.


Comments

There are no comments at the moment.