File tree Expand file tree Collapse file tree 4 files changed +49
-0
lines changed Expand file tree Collapse file tree 4 files changed +49
-0
lines changed File renamed without changes.
Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+ using namespace std ;
3
+
4
+ #define __INPUT__
5
+ #define __PRINT__
6
+ #define __DEBUG__
7
+
8
+ int N;
9
+ int U[1002 ];
10
+ vector<int > two;
11
+
12
+ int main () {
13
+ ios::sync_with_stdio (false );
14
+ cin.tie (NULL );
15
+
16
+ cin >> N;
17
+ for (int i = 1 ; i <= N; i++)
18
+ cin >> U[i];
19
+ sort (U + 1 , U + N + 1 );
20
+
21
+ for (int i = 1 ; i <= N; i++) {
22
+ for (int j = i; j <= N; j++) {
23
+ two.push_back (U[i] + U[j]);
24
+ }
25
+ }
26
+ sort (two.begin (), two.end ());
27
+ two.erase (unique (two.begin (), two.end ()), two.end ());
28
+
29
+ int ans = 0 ;
30
+ for (int i = N; i >= 1 ; i--) {
31
+ int target = U[i];
32
+ for (int j = i - 1 ; j >= 1 ; j--) {
33
+ int num = target - U[j];
34
+ if (binary_search (two.begin (), two.end (), num) == 1 ) {
35
+ ans = target;
36
+ break ;
37
+ }
38
+ }
39
+ if (ans != 0 )
40
+ break ;
41
+ }
42
+ cout << ans;
43
+ }
Original file line number Diff line number Diff line change
1
+ 5
2
+ 2
3
+ 3
4
+ 5
5
+ 10
6
+ 18
You can’t perform that action at this time.
0 commit comments