设为首页 加入收藏

TOP

HDU 4981 Goffi and Median(水)
2015-07-20 17:49:54 来源: 作者: 【 】 浏览:1
Tags:HDU 4981 Goffi and Median

HDU 4981 Goffi and Median

思路:排序就可以得到中间数,然后总和和中间数*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; }
     
    
   
  


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇关于 C++ 几个术语的简析--overlo.. 下一篇UVa10806_Dijkstra, Dijkstra.(网..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·哈希表 - 菜鸟教程 (2025-12-24 20:18:55)
·MySQL存储引擎InnoDB (2025-12-24 20:18:53)
·索引堆及其优化 - 菜 (2025-12-24 20:18:50)
·Shell 中各种括号的 (2025-12-24 19:50:39)
·Shell 变量 - 菜鸟教 (2025-12-24 19:50:37)