HDU 4974 A simple water problem(贪心)
来源:互联网 发布:爱国者之日 知乎 编辑:程序博客网 时间:2024/06/07 03:15
HDU 4974 A simple water problem
题目链接
签到题,很容易贪心得到答案是(sum + 1) / 2和ai最大值的最大值
代码:
#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int N = 100005;typedef long long ll;int t, n;ll a, Max, sum;int main() { int cas = 0; scanf("%d", &t); while (t--) {scanf("%d", &n);Max = 0;sum = 0;ll num = 0;for (int i = 0; i < n; i++) { scanf("%I64d", &num); Max = max(Max, num); sum += num;}sum = (sum + 1) / 2;printf("Case #%d: %I64d\n", ++cas, max(sum, Max)); } return 0;}
1 0
- HDU 4974 A simple water problem(贪心)
- hdu - 4974 - A simple water problem(贪心 + 反证)
- hdu - 4974 - A simple water problem(贪心 + 反证)
- HDU - 4974 A simple water problem
- hdu 4974 A simple water problem(水题)
- HDU - 4974 A simple water problem
- HDU 4974 A simple water problem
- HDU4974 A simple water problem(贪心)
- HDU 4974 A simple water problem 模拟(水
- hdu 4974 A simple water problem(数学题)
- hdu 4974——A simple water problem
- HDU 4967 A simple water problem
- A simple water problem
- 【杂题】 HDOJ 4974 A simple water problem
- HDOJ 4974 A simple water problem
- HDU4974:A simple water problem
- HDU4974 A simple water problem
- hdu 4974 A simple water problem(多校第十场 水题)
- Remember the Word - UVaLive 3942 Trie树+dp
- Lucene从入门到熟悉(三)分词
- 面试算法记录
- 按键消抖
- 戒骄戒躁,qt相关学习资料
- HDU 4974 A simple water problem(贪心)
- 协议系列之UDP协议
- IOS学习笔记-2
- STL map用法
- 【转】单例模式
- NSArray元素去重
- Codeforces 460C
- 1.1 World of Work
- shell脚本编程总结