【DP】 Light OJ 1004 Monkey Banana Problem
来源:互联网 发布:收获日2 a卡优化 编辑:程序博客网 时间:2024/04/28 13:46
点击打开链接
还是数塔。。
上面一堆用 -1
下面一堆用 +1(s[i]表示)
#include <cstdio>#include <cstring>#include <cstdlib>#include <string>#include <iostream>#include <algorithm>#include <sstream>#include <cmath>using namespace std;#include <queue>#include <stack>#include <set>#include <vector>#include <deque>#include <map>#define cler(arr, val) memset(arr, val, sizeof(arr))#pragma comment(linker, "/STACK:102400000,102400000")typedef long long LL;const int MAXN = 230+1;const int MAXM = 140000;const int INF = 0x3f3f3f3f;const int mod = 1000000007;LL a[320][320],len[320],s[320],dp[320][320];int main(){#ifndef ONLINE_JUDGE freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout);#endif int n,t,cas=1; cin>>t; while(t--) { int n; cin>>n; cler(a,0); cler(dp,0); for(int i=1;i<=n;i++) { len[i]=i; s[i]=-1; for(int j=1;j<=i;j++) scanf("%lld",&a[i][j]); } for(int i=n+1;i<2*n;i++) { len[i]=2*n-i; s[i]=1; for(int j=1;j<=len[i];j++) scanf("%lld",&a[i][j]); } for(int i=1;i<2*n;i++) { for(int j=1;j<=len[i];j++) { dp[i][j]=max(dp[i][j],dp[i-1][j+s[i]]+a[i][j]); dp[i][j]=max(dp[i][j],dp[i-1][j]+a[i][j]); } } printf("Case %d: %lld\n",cas++,dp[n*2-1][len[n*2-1]]); } return 0;}
0 0
- 【DP】 Light OJ 1004 Monkey Banana Problem
- Light oj 1004 - Monkey Banana Problem(DP)
- Light OJ 1004 - Monkey Banana Problem dp题解
- light oj 1004 - Monkey Banana Problem
- 1004 - Monkey Banana Problem (dp)
- Light oj-1004 - Monkey Banana Problem,数字三角形的变形版~
- ligh oj 1004 - Monkey Banana Problem
- LightOJ 1004 - Monkey Banana Problem 【DP】
- LightOJ 1004 - Monkey Banana Problem (dp)
- LightOJ - 1004 Monkey Banana Problem(DP)
- LightOJ 1004 - Monkey Banana Problem(dp)
- lightoj 1004 - Monkey Banana Problem 【dp】
- LightOJ-1004-Monkey Banana Problem [DP]
- LightOJ 1004 Monkey Banana Problem (线性dp 数字菱形)
- LightOJ 1004 Monkey Banana Problem (DP 数字三角形)
- LightOJ 1004 - Monkey Banana Problem
- lightoj 1004 - Monkey Banana Problem
- LightOJ 1004 Monkey Banana Problem
- sublime text 3 快捷键大全
- Facade模式
- 学习Python的感受-Python短小而精悍!
- 利用数学公式求开方
- 事务、存储过程——数据统一的守护神
- 【DP】 Light OJ 1004 Monkey Banana Problem
- 一致性hash算法分析
- Fiddler实现手机的抓包
- 深度定制 UIButton 按钮
- List ( interface ) 方法 总结
- MySQL二进制日志
- 【IOS 开发】Object-C 运算符
- 【水题】 ZOJ 3838 Infusion Altar
- UITextField 使用全面解析