HDU 4981 Goffi and Median
思路:排序就能够得到中间数。然后总和和中间数*n比較一下就可以
代码:
#include <cstdio> #include <cstring> #include <cmath> #include <algorithm> using namespace std; const int N = 1005; int n, a[N], sum; int main() { while (~scanf("%d", &n)) { sum = 0; for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); sum += a[i]; } sort(a + 1, a + n + 1); if (a[(n + 1) / 2] * n > sum) printf("YES "); else printf("NO "); } return 0; }