-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2108.cpp
More file actions
48 lines (43 loc) · 939 Bytes
/
2108.cpp
File metadata and controls
48 lines (43 loc) · 939 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
48
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
int num[8001];
int main() {
int n;
vector<int> vec;
scanf("%d", &n);
double sum = 0;
for (int i = 0; i < n; i++) {
int x;
scanf("%d", &x);
vec.push_back(x);
sum += x;
num[4000 + x]++;
}
sort(vec.begin(), vec.end());
bool first = true;
int most = -1;
int most_num = -4001;
vector<int> most_vec;
for (int i = 0; i < 8001; i++) {
if (most < num[i]) {
most_vec.clear();
most_vec.push_back(i - 4000);
most = num[i];
first = true;
}
else if (most == num[i]) {
most_vec.push_back(i - 4000);
first = false;
}
}
sort(most_vec.begin(), most_vec.end());
double mean = sum / (double)n;
printf("%0.f\n", mean);
printf("%d\n", vec[n / 2]);
if (!first) printf("%d\n", most_vec[1]);
else printf("%d\n", most_vec[0]);
printf("%d\n", vec[n - 1] - vec[0]);
}