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] ...
随机推荐
- 318. Maximum Product of Word Lengths
Given a string array words, find the maximum value of length(word[i]) * length(word[j]) where the tw ...
- UML大战需求分析阅读笔记2
全面深入理解客户的业务,才能帮助我们准确的把握客户的需要.而在理解客户业务的同时,我们往往需要做业务流程再造(BPR:Business Process Reengineering)的工作.BPR简单说 ...
- asp.net Ajax和web services
新建一个web服务 using System; using System.Collections.Generic; using System.Linq; using System.Web; using ...
- Brophp框架开发时连接数据库读取UTF8乱码的解决(转)
Brophp框架开发时连接数据库读取UTF8乱码的解决办法 (2012-09-15 10:41:22) 转载▼ 标签: 杂谈 it php 分类: 建站技术 Brophp框架开发时连接数据库读取UTF ...
- 北邮oj 题
题目描述 Every year,prince prepares a birthday gift for princess.The gift is a box,which is decorated wi ...
- LDAP与jenkins
1:下载:jenkins.war 2:运行:java -jar jenkins.war 一直让他开着,后者放到后台进程 3:在浏览器输入http://IP:8080 4:设置LDAP 若 ...
- 手机页面touch触摸事件
请看示例: <!DOCTYPE HTML> <html lang="en-US"> <head> <meta charset=" ...
- 使用PS过程
1. 设置图层背景色和前景色 设置背景色和前景色方法类似,下面以设置背景色为例说明.方法一:使用色板设置图片背景色第一步:单击"文件"菜单,选择"新建文档",这 ...
- DOS基本命令及其详解
指令格式:命令 选项 参数命令:要求计算机做某操作,可以是系统中的某个可执行程序,也可以是内存中的某函数.接口.别名等.如果是可执行程序,默认要带路径执行,除非该路径配置在环境变量path中.选项:表 ...
- hihocoder SAM基础概念
后缀自动机一·基本概念 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 小Hi:今天我们来学习一个强大的字符串处理工具:后缀自动机(Suffix Automaton,简称 ...