PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#TP0000062. Tập số và phương trình tổng (Sumsets)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Tập số và phương trình tổng (Sumsets)
Sumsets
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
You are given a set containing pairwise distinct integers. Choose four different elements such that .
Among all valid choices, find the largest value of . If no such choice exists, print exactly no solution. Elements can be negative, zero or positive.
Input
- The first line contains integer : the number of set elements.
- Each of the next lines contains exactly one distinct integer belonging to .
Output
Print the maximum possible , or exactly no solution in lowercase if no valid four-element choice exists.
Subtasks
- Subtask 1 (20 points): ; for all ; every two set elements are distinct.
- Subtask 2 (30 points): ; for all ; every two set elements are distinct.
- Subtask 3 (50 points): ; for all ; every two set elements are distinct.
Examples
Input
5
2
3
5
7
12
Output
12
Explanation
The set is . Choosing , , gives , and all four elements are distinct. Since is already the largest set element, no larger is possible. Therefore output 12.