-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2108.cpp
More file actions
46 lines (40 loc) · 761 Bytes
/
Copy path2108.cpp
File metadata and controls
46 lines (40 loc) · 761 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
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
int N;
cin >> N;
int count[8001] = { 0 };
int* arr = new int[N];
int sum = 0;
int max = 0;
int second = 0;
bool Is_second = false;
for (int i = 0; i < N; i++)
{
cin >> arr[i];
sum = sum + arr[i];
count[arr[i] + 4000]++;
}
sort(arr, arr + N);
for (int i = 0; i < 8001; i++)
{
if (count[i] > max)
{
max = count[i];
second = i - 4000;
Is_second = false;
}
else if (count[i] == max && !Is_second)
{
second = i - 4000;
Is_second = true;
}
}
cout << round(sum / (double)N) << endl;
cout << arr[N / 2] << endl;
cout << second << endl;
cout << arr[N - 1] - arr[0] << endl;
}