URALive 6510 Stickers(dp啊)
来源:互联网 发布:小意思托福 mac 编辑:程序博客网 时间:2024/05/23 11:51
题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4521
题意:
给出一个2*n的矩阵,取数使得到的结果最大,要求取的数不能有公共边。
代码如下:
#include <cstdio>#include <cstring>#include <algorithm>using namespace std;int a[3][100017], dp[3][100017];int main(){ int t; int n; scanf("%d",&t); while(t--) { scanf("%d",&n); for(int i = 1; i <= 2; i++) { for(int j = 1; j <= n; j++) { scanf("%d",&a[i][j]); } } memset(dp,0,sizeof(dp)); dp[1][1] = a[1][1]; dp[2][1] = a[2][1]; for(int j = 2; j <= n; j++) { dp[1][j] = max(dp[2][j-1],dp[2][j-2])+a[1][j]; dp[2][j] = max(dp[1][j-1],dp[1][j-2])+a[2][j]; } printf("%d\n",max(dp[1][n],dp[2][n])); } return 0;}
1 0
- URALive 6510 Stickers(dp啊)
- leetcode 691. Stickers to Spell Word(状压dp)
- UVALive 6510 Stickers
- 每日一题系列 - Compacting Stickers (ACM竞赛题)
- 691. Stickers to Spell Word
- iMessage Apps and Stickers, Part 1
- LWC 53:691. Stickers to Spell Word
- leetcode 691.Stickers to Spell Word
- leetcode -- 691. Stickers to Spell Word【动态规划 + 位图使用】
- leetcode691 Stickers to Spell Word 带记忆功能的回溯
- DP啊DP
- Lightoj1084【DP啊DP】
- dp啊
- URAL 1142. Relations(dp啊)
- ZOJ 3551 Bloodsucker(概率dp啊 )
- Stickers to Spell Word:多个单词拆拼接成完整以个目标单词所耗最小数目
- colors颜色的长度 (来自刘汝佳紫书) dp+dp+dp
- 区间DP -- 石子合并(朴素DP)
- 什么样子的人适合创业
- 【ThinkingInJava】23、反向迭代器
- 学习java一月感悟
- 蒜头学算术,计蒜客算法学习记录
- 第四单元 4.19
- URALive 6510 Stickers(dp啊)
- POJ Speed Limit
- scala 常见问题
- 牛人博客
- Hadoop FS Shell命令
- Baseadapter与Simpleadapter之争
- Java内部类详解
- 线程对象不能多次调用start函数开辟线程
- poj 3254(状态压缩dp)