PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000041. Ghép xiên nướng tối ưu (BBQ Easy)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Ghép xiên nướng tối ưu (BBQ Easy)
BBQ Easy
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
There are skewers of lengths . Each serving uses two unused skewers and can hold as many ingredients as the shorter skewer allows. Partition all skewers into pairs to maximize the total capacity.
Input
Line 1: integer . Line 2: integers .
Output
Print the maximum total capacity.
Subtasks
- Subtask 1 (20 points): ; for every .
- Subtask 2 (30 points): ; for every .
- Subtask 3 (50 points): ; for every .
Examples
Input
2
1 3 1 2
Output
3
Explanation
The four lengths are 1, 3, 1, 2. Pairing (1,1) yields 1 and (2,3) yields 2, totaling 3, which is optimal.