-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathccc17s3_2.cpp
More file actions
47 lines (37 loc) · 842 Bytes
/
ccc17s3_2.cpp
File metadata and controls
47 lines (37 loc) · 842 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
38
39
40
41
42
43
44
45
46
47
#include <vector>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n; cin >> n;
vector<int> nums(2001);
for (int i = 0; i < n; i++) {
int curr;
cin >> curr;
nums[curr]++;
}
// set<pair<int, int>> pairs;
vector<int> sums(4001);
int length = 0;
int times = 0;
for (int i = 0; i < 2000; i++) {
for (int j = i; j <= 2000; j++) {
if (i == j) sums[i+j] = nums[i]/2;
else sums[i+j] = min(nums[i], nums[j]);
}
}
for (int i : sums) {
if (i > length) {
length = i;
times = 1;
}
else if (i == length) {
times++;
}
}
cout << length << " " << times;
}