-
Notifications
You must be signed in to change notification settings - Fork 0
/
Midnight10057.cpp
48 lines (42 loc) · 899 Bytes
/
Midnight10057.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
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
// freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);
int n;
while(cin>>n){
vector<int> ans;
int tmp;
for(int i=0;i<n;i++){
cin>>tmp;
ans.push_back(tmp);
}
sort(ans.begin(),ans.end());
int mn,mm;
if(n%2){
mn=ans[n/2];
mm=ans[n/2];
}
else{
mn=ans[n/2-1];
mm=ans[n/2];
}
int num=0;
for(int i=0;i<n;i++){
if(ans[i]==mn||ans[i]==mm)
num++;
}
int s=0;
if(n%2)
s=1;
else
s=mm-mn+1;
cout<<mn<<' '<<num<<' '<<s<<'\n';
}
return 0;
}