-
Notifications
You must be signed in to change notification settings - Fork 0
/
ccc17s3.cpp
50 lines (47 loc) · 1.28 KB
/
ccc17s3.cpp
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
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
int N, X;
int sums[4001];
unordered_map<int, int> freq;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
memset(sums, 0, sizeof(sums));
cin >> N;
for (int i = 0; i < N; i++) {
cin >> X;
freq[X]++;
}
for (int i = 1; i <= 2000; i++){
for (int j = i; j <= 2000; j++){
int a = freq[i], b = freq[j];
if (a == 0 || b == 0) continue;
else {
// cout << i << " " << j <<"\n";
// cout << a << " " << b <<"\n";
// cout << "i+j = " << i+j << "\n";
if (i == j){
sums[i+j] += a/2;
} else {
sums[i+j] += min(a, b);
}
// cout << "sums["<<i+j <<"] = " << sums[i+j] << "\n";
// cout << "--------------------------------\n";
}
}
}
// for (int i = 1; i <= 4000; i++){
// sums[i] /= 2;
// }
int ans1 = 0, ans2 = 0;
for (int i = 1; i <= 4000; i++){
if (sums[i] > ans1){
ans1 = sums[i];
ans2 = 1;
} else if (sums[i] == ans1){
ans2++;
}
}
cout << ans1 << " " << ans2;
}