forked from sitz/UVa-Online-Judge
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path10057.cpp
More file actions
61 lines (55 loc) · 665 Bytes
/
10057.cpp
File metadata and controls
61 lines (55 loc) · 665 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
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <bits/stdc++.h>
using namespace std;
#define maxn 65536
int F[maxn + 2], N;
vector<int> V;
void Cal()
{
int n, m, c;
sort(V.begin(), V.end());
if (N % 2)
{
cout << V[N / 2];
cout << " " << F[V[N / 2]] << " "
<< "1\n";
}
else
{
n = V[N / 2];
m = V[N / 2 - 1];
c = F[n];
if (n != m)
{
c = F[n] + F[m];
}
cout << m << " ";
cout << c << " ";
cout << n - m + 1 << endl;
}
}
void ReSet()
{
int i;
for (i = 0; i < N; i++)
{
F[V[i]] = 0;
}
V.clear();
}
int main()
{
int n, m;
while (cin >> N && N)
{
m = N;
while (m--)
{
cin >> n;
F[n]++;
V.push_back(n);
}
Cal();
ReSet();
}
return 0;
}