标签:style blog http color os io for ar
签到题,很容易贪心得到答案是(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; }
HDU 4974 A simple water problem(贪心),布布扣,bubuko.com
HDU 4974 A simple water problem(贪心)
标签:style blog http color os io for ar
原文地址:http://blog.csdn.net/accelerator_/article/details/38737393