当前位置: 首页 > news >正文

洛谷P3146 [USACO16OPEN]248

 

题目描述

Bessie likes downloading games to play on her cell phone, even though she doesfind the small touch screen rather cumbersome to use with her large hooves.

She is particularly intrigued by the current game she is playing.The game starts with a sequence of positive integers (), each in the range . In one move, Bessie cantake two adjacent numbers with equal values and replace them a singlenumber of value one greater (e.g., she might replace two adjacent 7swith an 8). The goal is to maximize the value of the largest numberpresent in the sequence at the end of the game. Please help Bessiescore as highly as possible!

给定一个1*n的地图,在里面玩2048,每次可以合并相邻两个,问最大能合出多少

输入输出格式

输入格式:

The first line of input contains , and the next lines give the sequence

of numbers at the start of the game.

输出格式:

Please output the largest integer Bessie can generate.

输入输出样例

输入样例#1:
4
1
1
1
2
输出样例#1:
3

说明

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.

 

思路简直神奇

动规/递推

设f[i][j]为在[j]位置的数字[i]与它后面的数合并后的位置。

数最大为40,那么最大能合成到大概50+

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<algorithm>
 4 #include<cmath>
 5 #include<queue>
 6 #define LL long long
 7 using namespace std;
 8 const int mxn=300;
 9 int f[101][mxn];
10 int n;
11 int main(){
12     scanf("%d",&n);
13     int i,j;
14     int a;
15     for(i=1;i<=n;i++){
16         scanf("%d",&a);
17         f[a][i]=i+1;
18     }
19     int ans=0;
20     for(i=1;i<=60;i++){
21         for(j=1;j<=n;j++){
22             if(!f[i][j])f[i][j]=f[i-1][f[i-1][j]];
23             if(f[i][j])ans=i;
24         }
25     }
26     cout<<ans<<endl;
27     return 0;
28 }

 

转载于:https://www.cnblogs.com/SilverNebula/p/5927770.html

相关文章:

  • TechEd亲历图集
  • 秘制祖传正宗四川麻辣烫锅底配方
  • SqlPersistenceService数据库结构
  • 如何禁止内部viewPager滑动
  • ADO.NET 2.0 - 如何使用 DataView 来筛选数据
  • Sony DV的CCD也是有问题的
  • CakePHP中文手册【翻译】-请求处理组件
  • Itemplate自定义模板列
  • 委托的例子
  • 收藏
  • Linux的发行版及其不同发行版直接的联系与区别
  • 关于qq被盗问题.....
  • 实验五 利用三层交换机实现VLAN间路由
  • 去除开机自启动我的文档
  • 当阳光洒在脸上
  • 【Redis学习笔记】2018-06-28 redis命令源码学习1
  • Flex布局到底解决了什么问题
  • Git 使用集
  • JavaScript函数式编程(一)
  • Java的Interrupt与线程中断
  • java概述
  • java正则表式的使用
  • JDK9: 集成 Jshell 和 Maven 项目.
  • PhantomJS 安装
  • Phpstorm怎样批量删除空行?
  • python学习笔记-类对象的信息
  • Webpack入门之遇到的那些坑,系列示例Demo
  • 高度不固定时垂直居中
  • 入口文件开始,分析Vue源码实现
  • 适配iPhoneX、iPhoneXs、iPhoneXs Max、iPhoneXr 屏幕尺寸及安全区域
  • 新版博客前端前瞻
  • 《码出高效》学习笔记与书中错误记录
  • Java性能优化之JVM GC(垃圾回收机制)
  • 通过调用文摘列表API获取文摘
  • ​2020 年大前端技术趋势解读
  • ​Python 3 新特性:类型注解
  • ​如何使用ArcGIS Pro制作渐变河流效果
  • ​软考-高级-信息系统项目管理师教程 第四版【第23章-组织通用管理-思维导图】​
  • !$boo在php中什么意思,php前戏
  • $(selector).each()和$.each()的区别
  • (PyTorch)TCN和RNN/LSTM/GRU结合实现时间序列预测
  • (安卓)跳转应用市场APP详情页的方式
  • (二)Eureka服务搭建,服务注册,服务发现
  • (附源码)springboot学生选课系统 毕业设计 612555
  • (九)One-Wire总线-DS18B20
  • (五)大数据实战——使用模板虚拟机实现hadoop集群虚拟机克隆及网络相关配置
  • (转)IOS中获取各种文件的目录路径的方法
  • (轉貼) 寄發紅帖基本原則(教育部禮儀司頒布) (雜項)
  • ..回顾17,展望18
  • .bat批处理(五):遍历指定目录下资源文件并更新
  • .NET C#版本和.NET版本以及VS版本的对应关系
  • .Net Memory Profiler的使用举例
  • .Net 中的反射(动态创建类型实例) - Part.4(转自http://www.tracefact.net/CLR-and-Framework/Reflection-Part4.aspx)...
  • .net安装_还在用第三方安装.NET?Win10自带.NET3.5安装
  • .NET大文件上传知识整理