-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path26-45.cpp
More file actions
37 lines (30 loc) · 745 Bytes
/
26-45.cpp
File metadata and controls
37 lines (30 loc) · 745 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main() {
ifstream f("26-45.txt");
int n;
f >> n;
vector<int> a(n);
for (int i = 0; i < n; ++i) {
f >> a[i];
}
sort(a.begin(), a.end());
int k = 0, m = 0;
for (int i = 0; i < n - 1; ++i) {
for (int j = i + 1; j < n; ++j) {
if ((a[i] + a[j]) % 2 == 0) {
int s = (a[i] + a[j]) / 2;
if (binary_search(a.begin(), a.end(), s)) {
++k;
m = max(m, s);
}
}
}
}
cout << k << " " << m << endl;
return 0;
}