dti是什么意思_happygame是哪个应用

dti是什么意思_happygame是哪个应用2018.10.24-dtij-2636-262144(game)

大家好,又见面了,我是你们的朋友全栈君。

题目描述:

Bessie likes downloading games to play on her cell phone, even though she does find 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 N positive integers (2≤N≤262,144), each in the range 1…40. In one move, Bessie can take two adjacent numbers with equal values and replace them a single number of value one greater (e.g., she might replace two adjacent 7s with an 8). The goal is to maximize the value of the largest number present in the sequence at the end of the game. Please help Bessie score as highly as possible!

给定n个1到40之间的数,每次可以将两个相邻的相等的数替换成一个比它们大1的数(比如,相邻的7 7可以替换成8),你需要让最后剩下的数中的最大数尽量大

输入:

The first line of input contains N, and the next N lines give the sequence of N numbers at the start of the game.

输出:

Please output the largest integer Bessie can generate.

算法标签:DP(很常见的一个类似倍增的dp)

思路:

其实合并的过程很类似一个倍增的过程,且仔细分析发现数字的大小最大值58大概,所以就用

当f[i][j]!=0&&f[f[i][j]+1]!=0时可以有转移f[i][j+1]=f[f[i][j]+1][j];

以下代码:

dti是什么意思_happygame是哪个应用
dti是什么意思_happygame是哪个应用

#include<bits/stdc++.h>
#define il inline
#define _(d) while(d(isdigit(ch=getchar())))
using namespace std;
const int N=262150;int n,f[N][70],m;
il int read(){
    
    int x,f=1;char ch;_(!)ch=='-'?f=-1:f;x=ch^48;_()x=(x<<1)+(x<<3)+(ch^48);return f*x;}
int main()
{
    n=read();for(int i=1;i<=n;i++){
    
    int x=read();f[i][x]=i;m=max(m,x);}
    for(int i=1;i<=m;i++)for(int j=1;j<=n;j++)
        if(f[j][i]!=0&&f[f[j][i]+1][i]!=0){
            f[j][i+1]=f[f[j][i]+1][i];if(i+1>m)m=i+1;
        }printf("%d\n",m);
  return 0;
}

View Code

 

转载于:https://www.cnblogs.com/Jessie-/p/9845740.html

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/107236.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)
blank

相关推荐

  • java发送邮件mail.jar[通俗易懂]

    java发送邮件mail.jar[通俗易懂]这里短信发送是基于对mail.jar封装的jar包开发的,但是基本参数是一样的,可以参考packagecom.dw;importcom.dareway.framework.exception.AppException;importcom.dareway.framework.mail.MailInfo;importcom.dareway.framework.mail.Mail…

  • R语言doParallel+foreach 并行计算初试牛刀「建议收藏」

    R语言doParallel+foreach 并行计算初试牛刀「建议收藏」前言 因为我学习的需要,要做模拟,需要用到前人写好的函数,然后又需要大量的循环(模拟一百次,每次生成500条曲线,450条训练,50条做预测)。每次做个运算要半个小时左右,实在是受不了了之后,找了很多的博客和也下载了cran的帮助文档来看。最后终于一遍遍的试出来了。包的安装 首先需要将doParallel的包安装带上去,而doParallel的包基于foreach,iterators和par…

  • Ngixn动静分离详细配置方法

    Ngixn动静分离详细配置方法目录前言:准备工作一.静态主机配置二.动态主机配置三.动静分离配置四.配置文件目录结构五.测试前言:  为了加快网站的解析速度,可以把动态页面和静态页面由不同的服务器来解析,加快解析速度。降低原来单个服务器的压力。在动静分离的tomcat的时候比较明显,因为tomcat解析静态很慢,其实这些原理的话都很好理解,简单来说,使用正则表达式匹配过滤,然后交给不同的服务器。  静态页面一般直接由Nginx来处理,动态页面则是通过反向代理,代理到后端的Tomcat,然后在做负载均衡,是选择本地静态页面,还是后

  • pycharm windows 重置_pycharm重置设置,恢复默认设置「建议收藏」

    pycharm windows 重置_pycharm重置设置,恢复默认设置「建议收藏」备忘,备忘,备忘2020-03-23日更新,重置有问题的,请参考底部官网链接.(另外:喷我并不能解决你的问题.)window系统找到下方目录–>删除.再重新打开pycharm#WindowsVista,7,8,10:\Users\\.例:C:\Users\Administrator\.PyCharm2018.1#WindowsXP:\DocumentsandSett…

  • pychram激活码[最新免费获取]

    (pychram激活码)本文适用于JetBrains家族所有ide,包括IntelliJidea,phpstorm,webstorm,pycharm,datagrip等。https://javaforall.cn/100143.htmlIntelliJ2021最新激活注册码,破解教程可免费永久激活,亲测有效,上面是详细链接哦~C…

  • golang2022.1 激活吗(注册激活)

    (golang2022.1 激活吗)本文适用于JetBrains家族所有ide,包括IntelliJidea,phpstorm,webstorm,pycharm,datagrip等。https://javaforall.cn/100143.htmlIntelliJ2021最新激活注册码,破解教程可免费永久激活,亲测有效,上面是详细链接哦~B…

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号