PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#QHD0000054. Chia đều hành lý (Luggage)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Chia đều hành lý (Luggage)
Luggage
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
There are suitcases with positive integer weights . Every suitcase must be loaded intact into exactly one of two cars; no suitcase may be split or left behind. Determine whether the suitcases can be partitioned into two groups of equal total weight. Output only whether such a partition exists.
Input
The first line contains . The second line contains positive integers .
Output
Print YES if an equal partition exists, otherwise print NO (uppercase).
Subtasks
Scoring groups are independent. All constraints listed for a group apply simultaneously.
- Subtask 1 (20%): , and .
- Subtask 2 (30%): , and .
- Subtask 3 (50%): , and .
Examples
Input
4
1 5 11 5
Output
YES
Explanation
The total weight is . One car takes the -kg suitcase; the other takes kg, so both carry kg.