传送门啦

分析:

一个裸的区间dp,我们只需要注意合并的时候并不像2048那样加倍,每次都加1就好了

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
const int maxn = ; inline int read(){
int f = , x = ;
char ch = getchar();
while(ch > '' || ch < '') {if(ch == '-') f = -; ch = getchar();}
while(ch >= '' && ch <= ''){x = (x << ) + (x << ) + ch - ''; ch = getchar();}
return x * f;
} int n,m;
int f[maxn][maxn],ans; int main(){
n = read();
for(int i=;i<=n;i++) f[i][i] = read() , ans = max(ans , f[i][i]);
for(int i=n;i>=;i--)
for(int j=i+;j<=n;j++)
for(int k=i;k<=j;k++)
if(f[i][k] == f[k+][j]){
f[i][j] = max(f[i][j] , f[i][k] + );
ans = max(ans , f[i][j]);
}
printf("%d",ans);
return ;
}

[USACO16OPEN]248的更多相关文章

  1. 洛谷P3146 [USACO16OPEN]248

    P3146 [USACO16OPEN]248 题目描述 Bessie likes downloading games to play on her cell phone, even though sh ...

  2. 洛谷 P3146 [USACO16OPEN]248

    P3146 [USACO16OPEN]248 题目描述 Bessie likes downloading games to play on her cell phone, even though sh ...

  3. P3146 [USACO16OPEN]248

    P3146 [USACO16OPEN]248 题解 第一道自己码出的区间DP快庆祝一哈 2048 每次可以合并任意相邻的两个数字,得到的不是翻倍而是+1 dp[L][R] 区间 L~R 合并结果 然后 ...

  4. [USACO16OPEN]248 G——区间dp

    [USACO16OPEN]248 G 题目描述 Bessie likes downloading games to play on her cell phone, even though she do ...

  5. 「区间DP」「洛谷PP3146 」[USACO16OPEN]248 G

    [USACO16OPEN]248 G 题目: 题目描述 Bessie likes downloading games to play on her cell phone, even though sh ...

  6. 又一道区间DP的题 -- P3146 [USACO16OPEN]248

    https://www.luogu.org/problemnew/show/P3146 一道区间dp的题,以区间长度为阶段; 但由于要处理相邻的问题,就变得有点麻烦; 最开始想了一个我知道有漏洞的方程 ...

  7. 【动态规划DP】[USACO16OPEN]248

    题目描述 Bessie likes downloading games to play on her cell phone, even though she doesfind the small to ...

  8. P3146 [USACO16OPEN]248 & P3147 [USACO16OPEN]262144

    注:两道题目题意是一样的,但是数据范围不同,一个为弱化版,另一个为强化版. P3146传送门(弱化版) 思路: 区间动规,设 f [ i ][ j ] 表示在区间 i ~ j 中获得的最大值,与普通区 ...

  9. P3146 [USACO16OPEN]248 (区间DP)

    题目描述  给定一个1*n的地图,在里面玩2048,每次可以合并相邻两个(数值范围1-40),问最大能合出多少.注意合并后的数值并非加倍而是+1,例如2与2合并后的数值为3. 这道题的思路: 状态: ...

随机推荐

  1. fzyjojP2931 乱搞

    其实很简单(第二个不知是啥) 贡献独立 其实第一种就是考虑一个点在哈夫曼树上的期望深度是多少 因为精度要求较高 所以要高精小数加,高精小数除以低精整数

  2. JSON学习笔记(总结自w3school)

    1. JSON是一种文本. 2. JSON即JavaScript Object Notation(JavaScript对象表示法). JSON用来存储和交换文本信息. JSON比xml更小, 更快, ...

  3. K8S发布解释型语言应用的最佳实践

    说明 我们知道,k8s在发布编译型语言的应用时,几乎不用多考虑,就会选择将编译好jar/war包(java语言)或者二进制文件(golang/c++)直接打到镜像当中,生成新的应用镜像,然后将镜像推到 ...

  4. windows环境下批处理实现守护进程

    这个脚本提供两种方式守护,一种是通过进程名,但对于进程名都是java.exe的java程序不适用,另一种是通过netstat查找应用程序所监听的端口是否正在被监听.这两种方式可以在脚本中通过两个冒号注 ...

  5. PHP7 学习笔记(一)Ubuntu 16.04 编译安装Nginx-1.10.3、 PHP7.0.9、Redis3.0 扩展、Phalcon3.1 扩展、Swoole1.9.8 扩展、ssh2扩展(全程编译安装)

    ==================== PHP 7.0 编译安装================== wget http://cn2.php.net/get/php-7.0.9.tar.bz2/fr ...

  6. 单进程单线程的Redis如何能够高并发

    redis快的原因: 1.纯内存操作2.异步非阻塞 IO 参考文档: (1)http://yaocoder.blog.51cto.com/2668309/888374 (2)http://www.cn ...

  7. [转载]memset()的效率

    http://blog.csdn.net/hackbuteer1/article/details/7343189 void *memset(void *s, int ch, size_t n); 作用 ...

  8. 20155331 2016-2017-2 《Java程序设计》第5周学习总结

    20155331 2016-2017-2 <Java程序设计>第5周学习总结 教材学习内容总结 一.Java异常的基础知识 异常是程序中的一些错误,但并不是所有的错误都是异常,并且错误有时 ...

  9. 爬虫笔记之JS检测浏览器开发者工具是否打开

    在某些情况下我们需要检测当前用户是否打开了浏览器开发者工具,比如前端爬虫检测,如果检测到用户打开了控制台就认为是潜在的爬虫用户,再通过其它策略对其进行处理.本篇文章主要讲述几种前端JS检测开发者工具是 ...

  10. 解决多个python的兼容问题

    方法1:将(安装路径和scripts)路径添加到系统环境变量,谁的顺序在前面谁就是默认的 方法2:修改python的名字,然后再终端输入比如python2或者python3