HDU 5280 BestCoder Round#47 1001
来源:互联网 发布:软件测试28原则 编辑:程序博客网 时间:2024/05/17 09:21
Simple problem;
The portal:http://acm.hdu.edu.cn/showproblem.php?pid=5280
#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <iostream>using namespace std;long long a[1005];long long dp[1005];void Deal_with(){int T,n,p;scanf("%d",&T);while(T--){memset(dp,0,sizeof(dp));scanf("%d %d",&n,&p);for(int i=0;i<n;i++){scanf("%lld",a+i);}long long ans = -0x3f3f3f3f;for(int i=0;i<n;i++){long long temp = a[i];a[i] = p; dp[0] = a[0]; long long t_ans = dp[0]; for(int j=1;j<n;j++){ if(dp[j-1]+a[j]<a[j]){ dp[j] = a[j]; } else { dp[j] = dp[j-1] + a[j]; } } for(int j=1;j<n;j++){ if(dp[j] > t_ans) t_ans = dp[j]; } if(t_ans > ans)ans = t_ans;a[i] = temp;}printf("%lld\n",ans);}}int main(void) {//freopen("a.in","r",stdin);Deal_with();return 0;}
0 0
- HDU 5280 BestCoder Round#47 1001
- HDU 5280 BestCoder Round #47 1001:Senior's Array
- HDU 5280 BestCoder Round#47 1001 ---枚举+dp
- HDU BestCoder Round #48 1001
- BestCoder Round #47 ($) HDU 5280 Senior\'s Array
- HDU 5281 BestCoder Round #47 1002
- BestCoder round#3 1001 && Hdu 4907
- hdu 4989 Summary(BestCoder Round #8 1001)
- BestCoder Round #16 1001(hdu 5086)
- BestCoder Round #49 ($) HDU 5339 Untitled(1001)
- BestCoder Round #84 1001 hdu 5747 模拟
- hdu 5747 Aaronson (BestCoder Round #84 1001)
- BestCoder Round #47 ($) (hdu 5280 , hdu 5281 , hdu 5282 , hdu 5283)
- hdu 5641 BestCoder Round #75
- hdu 5643 BestCoder Round #75
- BestCoder Round #83(HDU 5680)
- HDU 5281 BestCoder Round #47 1002:Senior's Gun
- hdu 4883 bestcoder round 2 1001 TIANKENG’s restaurant
- [LeetCode]Remove Nth Node From End of List
- 47.不用加减乘除做加法
- 1034. 有理数四则运算(20)
- 我的产品经理求职之路——如何编写产品分析报告
- 一道面试题,找出0-99中没有插入的一个数
- HDU 5280 BestCoder Round#47 1001
- 黑马程序员——高新技术---Java基础—常用类_obiect类,Scanner类
- [LeetCode]Valid Parentheses
- android studio SSL BKS格式keystore文件加载
- jsp内置对象之-session对象
- CSS层叠样式表
- 当助教的日子
- iOS中的事件处理
- Linux环境下安装JDK