传送门啦

分析:

一个裸的区间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. Java考试题之十

    QUESTION 230 Given: 10. class One { 11. public One foo() { return this; } 12. } 13. class Two extend ...

  2. Java考试题之八

    QUESTION 139 Giventhe following directory structure: bigProject |--source | |--Utils.java ||--classe ...

  3. 封装个StringBuffer,用array join的方式拼接字符串

    (function(window) { var core_ArrPro = Array.prototype; var core_slice = core_ArrPro.slice; var core_ ...

  4. 解题:Poetize6 IncDec Sequence

    题面 差分原数列得到差分数组$dif$,这样对于$dif[2]->dif[n]$会多出来两个“空位置”$1$和$n+1$.然后区间加减就变成了使一个位置$+1$,另一个位置$-1$(可以对“空位 ...

  5. shiro权限认证与授权

    什么是shiro? Shiro是apache旗下一个开源框架,它将软件系统的安全认证相关的功能抽取出来,实现用户身份认证,权限授权.加密.会话管理等功能,组成了一个通用的安全认证框架. 为什么要用sh ...

  6. 在阿里云上无法使用mailx发送邮件的解决办法,验证可用。

    由于阿里云已将25端口封了(改用465端口),所以在ECS上往外发邮件时要作相应的配置才行. 使用的是163的企业邮箱,笔记简洁可用. 在阿里云的“安全组”开放645端口通行. 1.安装相应软件包: ...

  7. P1978 集合

    P1978 集合 题目描述 集合是数学中的一个概念,用通俗的话来讲就是:一大堆数在一起就构成了集合.集合有如 下的特性: •无序性:任一个集合中,每个元素的地位都是相同的,元素之间是无序的. •互异性 ...

  8. java基础-IO流对象之Properties集合

    java基础-IO流对象之Properties集合 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.Properties集合的特点 Properties类表示了一个持久的属性集. ...

  9. redhat6下安装centos的yum源

    因为redhat中的yum是收费的,未注册时不允许使用的,下面是挂载光盘后的情况,未挂载是没有yum命令.但是下面即便挂载了也是需要验证的 [root@localhost /]# yum instal ...

  10. why inline functions must be put in header files?

    [why inline functions must be put in header files?] 编译中有2个过程:compile.link.先进行compile,compile中把源代码编译成 ...