[USACO16OPEN]248
分析:
一个裸的区间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的更多相关文章
- 洛谷P3146 [USACO16OPEN]248
P3146 [USACO16OPEN]248 题目描述 Bessie likes downloading games to play on her cell phone, even though sh ...
- 洛谷 P3146 [USACO16OPEN]248
P3146 [USACO16OPEN]248 题目描述 Bessie likes downloading games to play on her cell phone, even though sh ...
- P3146 [USACO16OPEN]248
P3146 [USACO16OPEN]248 题解 第一道自己码出的区间DP快庆祝一哈 2048 每次可以合并任意相邻的两个数字,得到的不是翻倍而是+1 dp[L][R] 区间 L~R 合并结果 然后 ...
- [USACO16OPEN]248 G——区间dp
[USACO16OPEN]248 G 题目描述 Bessie likes downloading games to play on her cell phone, even though she do ...
- 「区间DP」「洛谷PP3146 」[USACO16OPEN]248 G
[USACO16OPEN]248 G 题目: 题目描述 Bessie likes downloading games to play on her cell phone, even though sh ...
- 又一道区间DP的题 -- P3146 [USACO16OPEN]248
https://www.luogu.org/problemnew/show/P3146 一道区间dp的题,以区间长度为阶段; 但由于要处理相邻的问题,就变得有点麻烦; 最开始想了一个我知道有漏洞的方程 ...
- 【动态规划DP】[USACO16OPEN]248
题目描述 Bessie likes downloading games to play on her cell phone, even though she doesfind the small to ...
- P3146 [USACO16OPEN]248 & P3147 [USACO16OPEN]262144
注:两道题目题意是一样的,但是数据范围不同,一个为弱化版,另一个为强化版. P3146传送门(弱化版) 思路: 区间动规,设 f [ i ][ j ] 表示在区间 i ~ j 中获得的最大值,与普通区 ...
- P3146 [USACO16OPEN]248 (区间DP)
题目描述 给定一个1*n的地图,在里面玩2048,每次可以合并相邻两个(数值范围1-40),问最大能合出多少.注意合并后的数值并非加倍而是+1,例如2与2合并后的数值为3. 这道题的思路: 状态: ...
随机推荐
- Android Studio快捷键设置之实现原eclipse中ctrl+m的全屏的效果
如下图,keymap设置成eclipse的的,但是鼠标双击最大化复原没有,ctr+M全屏也没有, 那么久在如下图的三个项目上添加鼠标双击和快捷键---自己方便好用,但不冲突的 Toggle full ...
- SenseTime Ace Coder Challenge 暨 商汤在线编程挑战赛 A. 地铁站
//其实比赛的时候就想到这方法了,但看到数据太吓人,就没写//看着标程,实际上就是这方法,太坑爹…… /* 假设值为k,对于图中任意两点,圆1半径k/t1,圆2半径k/t2 圆1与圆2的交集为可以设置 ...
- 常用Build-in Keywords
1. Variables |- Set variable |- Create list |- Evaluate |- Get Variable Value 2. Conditional |- Run ...
- C++模版详解(-)
C++模版: 模版时C++支持多参数多态的工具,使用模版可以为用户为类或函数声明一般模式,使得类的数据成员,或者成员函数的参数,返回值取得任意类型. 模版是一种对类型进行参数化的工具: 通 ...
- select标签和多行文本标签
一.多行文本textarea <form> <div> <textarea name="more"></textarea> < ...
- Kubelet资源预留
目录 Kubelet Node Allocatable 配置参数 配置示例 Kubelet Node Allocatable Kubelet Node Allocatable用来为Kube组件和Sys ...
- Ansible3: ansible.cfg配置说明
常用配置 Ansible默认安装好后有一个配置文件/etc/ansible/ansible.cfg,该配置文件中定义了ansible的主机的默认配置部分,如默认是否需要输入密码.是否开启sudo认证. ...
- 朝韩危机-Python模拟导弹互射
萨德系统是麻省理工学院的林肯实验室牵头开发的.林肯实验室可以说是美军方手中的一张王牌.二个反导系统(末段高空区域导弹防御(THAAD)系统,和 国家导弹防御系统(NMD))均由实验室牵头.它既是技术支 ...
- java web实现计划定时任务
java web实现定时计划任务 1.定义一个类继承TimerTask,在run方法中写上需要执行的逻辑 package com.mytask; import java.util.TimerTask; ...
- 笔记 jquery 的一个bug解决方法积累
本博客是自己在学习和工作途中的积累与总结,仅供自己参考,也欢迎大家转载,转载时请注明出处 当id或匹配条件中包含特殊字符时,浏览器控制台会报缺少")"的异常,解决办法目前有两个: ...