4580: [Usaco2016 Open]248
Description
Input
Output
Please output the largest integer Bessie can generate.
Sample Input
1
1
1
2
Sample Output
//In this example shown here, Bessie first merges the second and third 1s to obtain the sequence 1 2 2
, and then she merges the 2s into a 3. Note that it is not optimal to join the first two 1s.
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
int n,j,ans,f[][],a[];
int main()
{
scanf("%d",&n);
for (int i=;i<=n;i++) cin>>a[i];
for (int i=;i<=n;i++) f[i][i]=a[i];
ans=;
for (int len=;len<=n;len++)
for (int i=;i<=n-len+;i++)
{
j=i+len-;
for (int k=i;k<=j-;k++)
if (f[i][k]==f[k+][j]) f[i][j]=max(f[i][j],f[k+][j]+);
if (f[i][j]>ans) ans=f[i][j];
}
printf("%d\n",ans);
return ;
}
4580: [Usaco2016 Open]248的更多相关文章
- BZOJ 4580: [Usaco2016 Open]248
Description 一个序列,每次可以把相邻的两个数合为一个,价值+1,求最后的最大价值. Sol 区间DP. \(f[i][j]\) 表示 \(i-j\) 中合成一个数字为多少,转移就是枚举断点 ...
- bzoj4580: [Usaco2016 Open]248(区间dp)
4580: [Usaco2016 Open]248 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 255 Solved: 204[Submit][S ...
- 【bzoj4580】[Usaco2016 Open]248 区间dp
题目描述 Bessie likes downloading games to play on her cell phone, even though she does find the small t ...
- BZOJ4580: [Usaco2016 Open]248
n<=248个数字,可以进行这样的操作:将相邻两个相同的数字合并成这个数字+1,求最大能合成多少. f(i,j)--区间i到j能合成的最大值,f(i,j)=max(f(i,k)+1),f(i,k ...
- BZOJ4580/Luogu3147 [Usaco2016 Open]248
amazing #include <iostream> #include <cstdio> #include <cstring> #include <algo ...
- BZOJ 4576: [Usaco2016 Open]262144
Description 一个序列,每次可以将两个相同的数合成一个数,价值+1,求最后最大价值 \(n \leqslant 262144\) Sol DP. 这道题是 BZOJ 4580: [Usaco ...
- bzoj AC倒序
Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...
- bzoj Usaco补完计划(优先级 Gold>Silver>资格赛)
听说KPM初二暑假就补完了啊%%% 先刷Gold再刷Silver(因为目测没那么多时间刷Silver,方便以后TJ2333(雾 按AC数降序刷 ---------------------------- ...
- 【BZOJ 4580】【Usaco2016 Open】248
http://www.lydsy.com/JudgeOnline/problem.php?id=4580 区间dp,f(i,j)表示区间[i,j]全部合成一个数,这个数是多少. 可以归纳证明[i,j] ...
随机推荐
- Lucene 工作原理 之倒排索引
1.简介 倒排索引源于实际应用中需要根据属性的值来查找记录.这种索引表中的每一项都包括一个属性值和具有该属性值的各记录的地址.由于不是由记录来确定属性值,而是由属性值来确定记录的位置,因而称为倒排 ...
- leetCode 354. Russian Doll Envelopes
You have a number of envelopes with widths and heights given as a pair of integers (w, h). One envel ...
- MFC 不让程序显示在任务栏上
如果是对话框程序直接在对话框的 初始化时,修改样式 ModifyStyleEx(WS_EX_APPWINDOW,WS_EX_TOOLWINDOW); 但是对于多文档或是单文档,则没有对应的对话框样式需 ...
- Xcode Pod使用
安装pod 略.. 打开终端 cd 项目路径 (可以在xocde里项目右键show in Finder 讲工程目录拖入终端) 回车 vim podfile 回车 输入 :wq 保存 建立pod ...
- 主从LDAP
yum -y install compat-openldap必须得安装这个 1:在主上 备份 cp /etc/openldap/slapd.conf /etc/open ...
- iOS 判断设备型号
+ (NSString*)deviceString { // 需要#import "sys/utsname.h" struct utsname systemInfo; uname( ...
- java中的 FileWriter类 和 FileReader类的一些基本用法
1,FileWriter类(字符输出流类) |--用来写入字符文件的便捷类.此类的构造方法假定默认字符编码和默认字节缓冲区大小都是可接受的.要自己指定这些值,可以先在 FileOutputStream ...
- maven css/js 压缩配置
<plugin> <groupId>net.alchim31.maven</groupId> <art ...
- java_js_json_日期格式化
调用方法: var createBeginTime= createBeginTime.Format("yyyy-MM-dd 00:00:00"); 方法: Date.prototy ...
- notepad++的CoolFormat代码格式化插件使用
因为notepad++的NppAStyle插件只支持格式化C.C++.C#.Java这四种编程语言的代码,所以本人推荐使用这个CoolFormat的插件,相比于NPPAStyle,CoolFormat ...