思路:排序就可以得到中間數,然後總和和中間數*n比較一下即可
代碼:
#include#include #include #include 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; }