PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#TP0000035. Cuộc thi đua thuyền (Boats Competition)
HỌC THEO LỘ TRÌNH
2 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Cuộc thi đua thuyền (Boats Competition)
Boats Competition
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
There are participants in a boat competition, and participant weighs . Each team consists of exactly two distinct participants, and no participant may belong to more than one team. All formed teams must have the same total weight . You may choose to maximize the number of teams. Determine that maximum.
Input
- The first line contains , the number of participants.
- The second line contains exactly integers , their weights.
Output
Print one integer: the maximum possible number of disjoint teams sharing a common total weight .
Subtasks
- Subtask 1 (20 points): ; for all .
- Subtask 2 (30 points): ; for all .
- Subtask 3 (50 points): ; for all .
Examples
Input
5
1 2 3 4 5
Output
2
Explanation
Choose . Pair weights and , then and . The participant of weight remains unpaired. Since five participants can form at most disjoint teams, two is optimal.