hdu 4374 One hundred layer 单调队列优化dp

[DP] hdu 4374 One hundred layer #单调队列优化 /** [DP] hdu 4374 One hundred layer #单调队列优化 有一个的楼房,从第一层某个位置出发上楼,每次能爬上一层楼也可以在同一层左右移动, 但是在每一层的移动距离不能超过某个值。。现在每个位置都有一个数值, 求从第一层出发到最后一层经过的路径上最多能取到的最大价值。 向右走时 dp[i][j] = max(dp[i-1][k] + sum[i][j 阅读详情

One hundred layer

Time Limit: 1000ms
Memory Limit: 65536KB
This problem will be judged on HDU.
Original ID: 4374
64-bit integer IO format: %I64d Java class name: Main

Now there is a game called the new man down 100th floor. The rules of this game is:
  1. At first you are at the 1st floor. And the floor moves up. Of course you can choose which part you will stay in the first time.
  2. Every floor is divided into M parts. You can only walk in a direction (left or right). And you can jump to the next floor in any part, however if you are now in part “y”, you can only jump to part “y” in the next floor! (1<=y<=M)
  3. There are jags on the ceils, so you can only move at most T parts each floor.
  4. Each part has a score. And the score is the sum of the parts’ score sum you passed by.
Now we want to know after you get the 100th floor, what’s the highest score you can get.

Input

The first line of each case has four integer N, M, X, T(1<=N<=100, 1<=M<=10000, 1<=X, T<=M). N indicates the number of layers; M indicates the number of parts. At first you are in the X-th part. You can move at most T parts in every floor in only one direction.
Followed N lines, each line has M integers indicating the score. (-500<=score<=500)

Output

Output the highest score you can get.

Sample Input

3 3 2 1
7 8 1
4 5 6
1 2 3

Sample Output

29

中文题意

给一个n*m的举证,从第一行的x处,走到最后一行,求途中经过的数字和最大,每行最多能朝一个方向走t步.

题解

很容易想到dp方程, dp[i][j]代表走到第i行第j列,并且下一步到第i+1行的最大值
先从左到右 : dp[i][j] = max(dp[i-1][k] + sum[i][j] - sum[i][k-1])
再从右到左 : dp[i][j] = max(dp[i-1][k] + sum[i][k] - sum[i][j-1])
(sum[i][j]代表第i行的前j个的和)
很明显如果暴力枚举每一个k的话,会超时,再仔细想想,其实对于每个dp[i][j], 我们需要的
仅仅是第i-1行在t步范围内的最大的dp[i-1][k]-sum[i][k-1], 然后把这个最大值加上sum[i][j]
就是从左到右的dp[i][j]的答案。这时候就可以想到用一个单调队列维护这个最大值了,可以
维护队首最大,每次从队尾入队,并保证单调性(把小的删掉),并把队首不在t步范围内的
删掉。然后分别从左到右,从右到左这样搞一遍,答案就出来了。

#include <set>
#include <map>
#include <cmath>
#include <deque>
#include <queue>
#include <vector>
#include <string>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long Long;
const int maxn = 100 + 10;
const int maxm = 1e4 + 10;
const int inf = 0x3f3f3f3f;
int arr[maxn][maxm], sum[maxn][maxm], dp[maxn][maxm];
deque<int> Q;

int main()
{ 
    int n, m, x, t; 
    while (scanf("%d%d%d%d", &n, &m, &x, &t) != EOF)
    {
        memset(sum, 0, sizeof(sum));
        for (int i = 1; i <= n; i++)
        {
            for (int j = 1; j <= m; j++)
            {
                scanf("%d", &arr[i][j]);
                sum[i][j] = sum[i][j-1] + arr[i][j];
            }
        }
        for (int i = 0; i <= n; i++) 
        {
            for (int j = 0; j <= m; j++) 
            {
                dp[i][j] = -inf;
            }
        }
        dp[0][x] = 0;
        for (int i = 1; i <= n; i++)
        {
            Q.clear();
            for (int j = 1; j <= m; j++)
            {
                while (!Q.empty() && dp[i-1][Q.back()]-sum[i][Q.back()-1] <= 
                    dp[i-1][j] - sum[i][j-1])
                {
                    Q.pop_back();
                }
                while (!Q.empty() && Q.front() < j-t)
                {
                    Q.pop_front();
                }
                Q.push_back(j);
                dp[i][j] = max(dp[i][j], dp[i-1][Q.front()]-sum[i][Q.front()-1] + 
                    sum[i][j]);
            }
            Q.clear();
            for (int j = m; j >= 1; j--)
            {
                while (!Q.empty() && dp[i-1][Q.back()]+sum[i][Q.back()] <= 
                    dp[i-1][j] + sum[i][j])
                {
                    Q.pop_back();
                }
                while (!Q.empty() && Q.front() > j+t)
                {
                    Q.pop_front();
                }
                Q.push_back(j);
                dp[i][j] = max(dp[i][j], dp[i-1][Q.front()]+sum[i][Q.front()] - 
                    sum[i][j-1]);
            }
        }
        int ans = -inf;
        for (int i = 1; i <= m; i++) {
            ans = max(ans, dp[n][i]);
        }
        printf("%d\n", ans);
    }
    return 0;
}
密码学小白必看:三大顶级会议论文下载与阅读指南(附完整资源链接) 本文为密码学初学者提供了系统获取和阅读三大顶级会议(Crypto、Eurocrypt、Asiacrypt)论文的实战指南。详细介绍了通过IACR官方渠道、ePrint预印本等权威资源免费下载论文的方法,并分享了高效筛选、精读核心章节及构建个人知识体系的具体策略,帮助读者快速切入密码学研究前沿。 阅读详情

相关推荐

cadence capture CIS 之添加数据库

2021-08-20 cadence capture CIS 之添加数据库准备一、添加数据源 准备 1、数据库文件(*.mdb) 2、电脑上安装好 cadence 软件 一、添加数据源 打开“ ODBC数据源管理器” ( 路径:C:\Windows\SysWOW64\odbcad32.exe ) ...

weixin_42256550的博客 6053

HDU-4347-One hundred layer-dp-单调队列优化

HDU-4347-One hundred layer-dp-单调队列优化 【Description】 Now there is a game called the new man down 100th floor. The rules of this game is:    1. At first you are at the 1st floor. And the floor mo...

Simon的博客,已转移至 https://www.cnblogs.com/--Simon/ 280

ORCA(动态避障)算法

A物体沿着向量v1和v2移动,刚好能和B擦肩而过,不会发生碰撞;若V1和V2的夹角再小一点的话就一定会发生碰撞。A的速度为V1,B的速度为V2,A对于B的相对速度(也就是我们把B看做静止,A的速度)就是V1-V2。,那么怎么判定A的速度向量是不是在碰撞区域内呢?这就需要用A相对于B的速度来判定。红线画出来的锥形区域就是A相对于B的。

u012861978的专栏 4769

MUTC8 E- One hundred layer 单调队列dp

One hundred layer Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1257    Accepted Submission(s): 467 Problem Description Now there

Azarath Metrion Zinthos 1117

18650电池组流体直冷热管理仿真:COMSOL多物理场耦合建模路线与实战策略

在动力电池与储能系统的热管理设计中,多物理场耦合仿真已成为平衡性能与成本的关键工具。液冷方案的换热极限促使行业转向制冷剂直冷技术,而两相流与电池产热的强耦合特性,使得基于COMSOL的数值建模成为评估系统温升与流动分配的重要手段。工程实践中,电化学-热-流场全耦合模型与集总电池-流场简化模型各有适用场景,前者揭示电池内部微观机理,后者则以高计算效率支撑包级方案迭代。通过合理简化几何、标定内阻与熵热系数、设置等效换热边界,仿真能够准确预测直冷系统在快充或大倍率放电下的温度均匀性与压降特性,从而指导流道优化与制

weixin_33585822的博客 314

台达B3伺服电机485通讯的调试过程

最近上了一项目,没办法直接把B3伺服接到PLC上去,怎么办?偶说试下直接电脑通过100多米的485线控制好了,定型前的测试就这样展开了。 1、焊CN1口 如果不安装CN1,是开不了机的,要报很多错误,比如SERV EMG ALERT, 上限报警,下限报警什么的,怎么办?直接焊好CN1头子吧,烦了点,但是必要的。 主要接的是11,9,10,32,31,30几个脚,按照图上连接好就是了。 2、 接线路 按照上面的图,接上伺服电机线,编码器线,电源线,包括限位常闭开关、485连线等,就完..

shidong01的博客 1万+

hdu4374 One hundred layer

Home Problems         -0:09:37 Overview Problem Status Rank A B C D E F G H I J K L M N O B - One hundred layer Time Limit:1000MS     Memory Limit:

习惯与规则决定命运 1273

保姆级教程:手把手教你下载和配置Waymo自动驾驶数据集(附百度网盘链接)

本文提供了一份详细的Waymo自动驾驶数据集下载和配置指南,特别针对国内研究者优化了数据获取方案,包括百度网盘链接和Google Cloud CLI配置。文章还涵盖了环境配置、数据处理实战、可视化分析以及进阶技巧,帮助开发者高效利用这一业界黄金标准数据集进行自动驾驶研究。

weixin_42651281的博客 360

hdu4374单调队列+dp

http://acm.hdu.edu.cn/showproblem.php?pid=4374 Problem Description Now there is a game called the new man down 100th floor. The rules of this game is:   1.  At first you are at the 1st floor.

ACM,再见! 1271

【Latex】【附安装文件】Miktex和TexStudio的安装与配置

这代表“构建并运行”,一般来说,我们只需要点这个按钮来运行Latex代码。保存一下代码文件,再运行一次,PDF文件会出现在与代码文件相同的文件夹下。安装完成后,你可能会跳转到一个页面中,你看到这个页面就意味着安装成功了。其实不需要你敲,你只要将下面的代码复制粘贴到你刚刚的文件中即可。成功安装MikTex后,我们需要进行更新,减少后续使用的麻烦。如果懂得将安装路径设置在你想要的盘中,你可以自己设置。双击上文的.exe文件后,你会看到如下画面。如果不懂,为避免不必要的麻烦,请直接点击“

未来就在脚下。 1万+

学Simulink——基于Simulink的超前-滞后校正控制器设计与仿真建模示例

本文完成了基于 Simulink 的超前-滞后校正控制器设计与仿真,实现了:✅掌握超前与滞后校正的物理意义与设计流程✅分步设计复合控制器,兼顾动态与稳态✅在 Simulink 中搭建闭环系统并验证卓越性能✅达成高稳定裕度、高精度、快速响应三大目标。

xiaoheshang_123的博客 78

HDU4374:One hundred layer(dp+单调队列优化)

One hundred layer Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 2172Accepted Submission(s): 748 Problem Description N...

weixin_33769207的博客 163

GEE案例:计算区域生态总体脆弱性分析

计算区域生态总体脆弱性分析需要考虑多个指标和因素。下面是一个基本的方法:选择指标:选择一组能够反映区域生态系统脆弱性的指标。这些指标可以包括生物多样性指数、森林覆盖率、湿地保护率、土地退化程度等。为每个指标分配权重:为了使得各指标在计算中的重要性相对均衡,可以为每个指标分配一个权重。权重可以根据各指标的重要性和可利用的数据进行确定。数据收集和处理:收集每个指标的数据,并对其进行处理,确保数据的准确性和一致性。如果有需要,可以对数据进行归一化处理。计算指标值:根据收集的数据和权重,计算每个指标的值。

此星光明博客 465

HDU 4374 One hundred layer(单调队列优化dp)

题意:有一个n*m的矩阵,每格有一个分数,一个人站在(1,x)位置,在每一行中,他只能朝一个方向走(向左或向右),且最多走t步,问走到最后第n行得到的最大分数。 思路:不难想到状态转移方程dp[i][j] = max(dp[i-1][k]+sum[i][j]-sum[i][k-1]),(k 移项得 dp[i][j]-sum[i][j] = max(dp[i-1][k] - sum[i][k-

GODSPEED 938

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

hdu 4374 One hundred layer(单调队列优化dp)

http://acm.hdu.edu.cn/showproblem.php?pid=4374 题意:简化一下,有一个n*m的矩阵,每格有一个分数,一个人站在(1,x)位置,在每一行中,他只能朝一个方向走(向左或向右),且最多走t步,问走到最后第n行得到的最大分数。 思路:dp[i][j]表示i行 j列位置的最大分数,若从左到右,dp[i][j] = max(dp[i-1][k]+sum[j]-

1273

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

【HDU4374】One hundred layer-单调队列优化DP

【HDU4374】One hundred layer-单调队列优化DP

Maxwei_wzj的OI世界 458

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

HDU 4374 One hundred layer [单调队列优化DP]

  N层楼,每层M个有分数的格子,一开始在第一层的S点,每层最多不能连续走T个就必须下楼,求到达最底层能获得的最大分数。   经典的单调队列优化问题,用A[i][j]表示前缀和,now表示当前层,pre表示上一层,可以得到以下递推式:   当前层从左向右走,d[now][i]=max(d[pre][j]+A[now][i]-A[now][j-1]) = max((d[pre][j]-A[now...

weixin_33895604的博客 119

HDU 4374 One hundred layer DP的单调队列优化

One hundred layer Problem Description Now there is a game called the new man down 100th floor. The rules of this game is:  1.At first you are at the 1st floor. And the floor moves up. Of cou...

weixin_30367543的博客 131

HDU 4374 One hundred layer(DP+单调队列优化)

题目链接 比赛的时侯非常暴力来了个N*M*T的算法,状态方程虽然好想,不会优化。。认真学习一下单调队列优化,看了很多博客+题解,其实原理也不难理解。 这个题状态转移,从左边来的 dp[i][j] = dp[i-1][k] + dis(k,j) 先预处理出一个sum数组存每一行前i个元素的和,dp[i][j] = dp[i-1][k] + sum[i][j]-sum[i][k-1]; 这就可...

weixin_30299709的博客 100

hdu4374 One hundred layer

单调队列优化dp 单调队列可以有两个操作: 1、插入一个新的元素,该元素从队尾开始向队首进行搜索,找到合适的位置插入之,如果该位置原本有元素,则替换它。 2、在过程中从队首删除不符合当前要求的元素。   单调队列实现起来可简单,可复杂。简单的一个数组,一个head,一个tail指针就搞定。复杂的用双向链表实现。   用处: 1、保存最优解,次优解

MetalSeed 1407

hdu 4374 One hundred layer

第一道单调队列优化的DP,好麻烦从晚上11点看到第二天3点,终于会了。这个题目就是一传说中的是男人就下100层为模型,题目说了一个起始的位置,然后你一次最多朝一个方向(这一点很重要)走一定的步数,现在问你到最后一层能得到的最大的分数。这个题目的DP还是很明显的,当时一看这个题目就呵呵了,状态的转移很明显是dp[i][j]到达第i层第j个位置的最大获取值。当是从左边走的时候也就是从左向右走,dp[i

kungfu panda 1011

HDU-4374-One hundred layer

DP+单调队列维护 代码: #include #include #include using namespace std; const int inf=1<<29; const int maxn=110; const int maxm=10010; struct Node { int val; int pos; Node(){} Node(int sval,in

z309241990的专栏 876

hdu 4374 One hundred layer【单调队列DP】

One hundred layer Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1131    Accepted Submission(s): 422 Problem Description Now there is

smallfish的专栏 427

hdu4374 One hundred layer(单调队列维护dp)

题面题意 给出宽n,长m的矩阵,你一开始在第一行第k个,在每行你最多向左或向右移动t步(在底层和顶层皆可移动),移动后进入下一层,问到达底层后的最大分数是多少. 方法 用dp思想可知,只需要知道到达每一点的最大得分是多少,若穷举每行的起点和终点进行状态转移,复杂度为O(n*m^2)必然TLE. 其实在第i行若终点为j,则起点必然在max(1,j-t)与min(m,j+t)之间,对于此类

yzyyylx的博客 332
上一篇: ACM常用定理
下一篇: mac下使用自带的vim编辑器编辑文件
吃掉吃掉
博客等级 码龄12年 7粉丝 30原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值