File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ ``` java
2+ import java.util.* ;
3+ import java.io.* ;
4+
5+ public class Main {
6+ static BufferedReader br = new BufferedReader (new InputStreamReader (System . in));
7+ static BufferedWriter bw = new BufferedWriter (new OutputStreamWriter (System . out));
8+ static int N ;
9+ static int [] arr;
10+
11+ public static void main (String [] args ) throws Exception {
12+ N = Integer . parseInt(br. readLine());
13+ arr = new int [N ];
14+
15+ for (int i = 0 ; i < N ; i++ ) {
16+ arr[i] = Integer . parseInt(br. readLine());
17+ }
18+ Arrays . sort(arr);
19+
20+ Set<Integer > sums = new HashSet<> ();
21+ for (int i = 0 ; i < N ; i++ ) {
22+ for (int j = 0 ; j < N ; j++ ) {
23+ sums. add(arr[i] + arr[j]);
24+ }
25+ }
26+
27+ a: for (int i = N - 1 ; i >= 0 ; i-- ) {
28+ for (int j = 0 ; j <= i; j++ ) {
29+ if (sums. contains(arr[i] - arr[j])){
30+ bw. write(arr[i] + " " );
31+ break a;
32+ }
33+ }
34+ }
35+ bw. close();
36+ }
37+ }
38+ ```
You can’t perform that action at this time.
0 commit comments