8000 solved 0x13 2295 · jo0n-lab/basic-algo-lecture@bed09ad · GitHub
[go: up one dir, main page]

10000 Skip to content

Commit bed09ad

Browse files
author
cuberry
committed
solved 0x13 2295
1 parent ecb43e4 commit bed09ad

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed
File renamed without changes.

0x13/v2295/main

46 KB
Binary file not shown.

0x13/v2295/main.cc

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
}

0x13/v2295/tc1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
5
2+
2
3+
3
4+
5
5+
10
6+
18

0 commit comments

Comments
 (0)
0