UVa10057

題目:
https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=12&page=show_problem&problem=998

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
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);

int n;
while(cin >> n){
vector<int> v(n);
for(int i=0; i<n; ++i) cin >> v[i];
sort(v.begin(), v.end());
int a = v[(n-1)/2];
int b = v[n/2];
int first = a;
int second = 0;
for(int x : v){
if(x >= a && x <= b) ++second;
}
int third = b-a+1;

cout << first << ' ' << second << ' ' << third << '\n';
}
return 0;
}