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\n"); else printf("NO\n"); } return 0; }
本文转自mfrbuaa博客园博客,原文链接:http://www.cnblogs.com/mfrbuaa/p/5135261.html,如需转载请自行联系原作者