PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000135. Topforces phản công (Topforces Strikes Back)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Topforces phản công (Topforces Strikes Back)
Topforces Strikes Back
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
There are problems with positive attractiveness values . Select between one and three problems so that, for every pair of selected values, neither value divides the other. Maximize the sum of their attractiveness. Equal values from different positions cannot be chosen together because they divide each other.
Input
The first line contains ; the next contains integers .
Output
Print the maximum total attractiveness of a valid selection.
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Input
4
10 6 30 15
Output
31
Explanation
Choosing 10, 6 and 15 gives sum 31, and none divides another. Choosing 30 excludes each of those values and yields only 30, so 31 is optimal.