POJ3264 Balanced Lineup

renderdoc的使用 renderdoc可以用来捕获帧渲染情况,排查一些GPU渲染、资源规格等问题。 下面讲述一些该软件连接真机调试使用。 一、下载安装renderdoc 软件的下载地址:https://renderdoc.org/可直接点击下载即可。该软件是开源免费的,不用破解。 下载后直接安装即可使用。 二、打开使用renderdoc 打开界面后,默认的界面布局如下图所示,(这里我已经设置了黑色主题,可以忽略这点),renderdo中主要的窗口有Texture Viewer(纹理查看器)、Event B. 阅读详情

这道题很基础,几乎就是一个ST算法的模板。

第一次接触ST算法可以用这道题来练习算法。

 

Balanced Lineup
Time Limit: 5000MS Memory Limit: 65536K
Total Submissions: 23289 Accepted: 10827
Case Time Limit: 2000MS

Description

For the daily milking, Farmer John's N cows (1 ≤ N ≤ 50,000) always line up in the same order. One day Farmer John decides to organize a game of Ultimate Frisbee with some of the cows. To keep things simple, he will take a contiguous range of cows from the milking lineup to play the game. However, for all the cows to have fun they should not differ too much in height.

Farmer John has made a list of Q (1 ≤ Q ≤ 200,000) potential groups of cows and their heights (1 ≤ height ≤ 1,000,000). For each group, he wants your help to determine the difference in height between the shortest and the tallest cow in the group.

Input

Line 1: Two space-separated integers, N and Q.
Lines 2..N+1: Line i+1 contains a single integer that is the height of cow i
Lines N+2..N+Q+1: Two integers A and B (1 ≤ A ≤ B ≤ N), representing the range of cows from A to B inclusive.

Output

Lines 1..Q: Each line contains a single integer that is a response to a reply and indicates the difference in height between the tallest and shortest cow in the range.

Sample Input

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

Sample Output

6
3
0

 

 

#include<iostream>
#include<cstring>
#include<cmath>

using namespace std;

int dp1[50050][20];  //min
int dp2[50050][20];  //max
int cow[50050];
int n,m;

int max(int a,int b)
{
	return a>b?a:b;
}

int min(int a,int b)
{
	return a<b?a:b;
}

void init()
{
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&cow[i]);
		dp1[i][0]=dp2[i][0]=cow[i];
	}
	int k=floor(log((double)(n+1))/log(2.0));
	int m;
	for(int j=1;j<=k;j++)
		for(int i=0;i+(1<<j)-1<=n;i++)
		{
			m=i+(1<<(j-1));
			dp1[i][j]=min(dp1[i][j-1],dp1[m][j-1]);
			dp2[i][j]=max(dp2[i][j-1],dp2[m][j-1]);
		}
}

int rmq(int i,int j)
{
	int m=floor((log((double)(j-i+1))/log(2.0)));
	int x=max(dp2[i][m],dp2[j-(1<<m)+1][m]);
	int y=min(dp1[i][m],dp1[j-(1<<m)+1][m]);
	return x-y;
}

int main()
{
	while(cin>>n>>m)
	{
		init();
		int x,y;
		for(int i=1;i<=m;i++)
		{
			scanf("%d%d",&x,&y);
			cout<<rmq(x,y)<<endl;
		}	
	}
	return 0;
}


 

 

人形机器人新产品导入(NPI)工艺工程师的角色与技术解析 本文系统解析人形机器人NPI工程师的核心职责与能力要求。主要内容包括:1)NPI工程师需主导装配工艺设计、样品试做及问题闭环,涉及公差分析(如尺寸链计算)、工艺评审与FMEA应用;2)要求输出完整工艺文档体系,并跟踪试产至量产全过程;3)任职资格强调3年以上机器人/智能制造行业经验,掌握SPC、公差计算等质量工具,熟悉点胶/焊接等工艺及特殊材料特性;4)通过实际案例展示关节精度优化、新物料验证等典型工作场景;5)提供基于职责的面试问题及技术性解答方案。文章聚焦技术细节,为从业者提供实用参考框架。 阅读详情

相关推荐

AD9176 双通道高速DAC调试记录

AD9176是一款高性能双通道16位数模转换器,支持高达12.6GSPS采样率,专为多频段无线应用设计。该器件集成8通道15.4Gbps JESD204B接口,支持复数/实数数据输入,每通道最大输入速率达3.08GSPS。关键特性包括:48位高精度NCO、灵活的插值滤波器(最高12倍)、优异的动态性能(SFDR达-83dBc@1.84GHz)以及多芯片同步功能。硬件调试需重点关注时钟配置(建议250M基准时钟)、JESD参数匹配及交流耦合设计。测试指标要求SFDR>55dBc@312MHz,实测值可达65d

universaldata的博客 1502

[POJ3264]Balanced Lineup 做题笔记

·· / ·– ·· ·-·· ·-·· / ·–· · ·-· ··· ·· ··· - / ··- -· - ·· ·-·· / ·· / ·– ·· -· 题目来源:http://poj.org/problem?id=3264 这题是基本的rmq问题,可以用st算法来解决。本来是不想把这题贴上来的,但代码里有个奇怪的鲠! 代码里的u,v一定要定义到全局,否则直接wa,但是u,v在main

mhlwsk的博客 490

AMEsim不连续处理机制:仿真精度与效率的平衡艺术

本文深入解析AMEsim不连续处理机制在系统仿真中的应用,探讨如何平衡仿真精度与效率。通过液压系统仿真案例,详细介绍了事件检测算法、变步长求解器自适应策略及典型场景优化方法,帮助工程师有效应对仿真中的不连续性问题,提升仿真效率和准确性。

v4w5x6的博客 444

POJ 3264 Balanced Lineup

POJ 3264 Balanced Lineup 题目链接 Description For the daily milking, Farmer John’s N cows (1 ≤ N ≤ 50,000) always line up in the same order. One day Farmer John decides to organize a game of Ultimate Frisbee with some of the cows. To keep things simple, he wil

旺崽的博客 2709

SpyGlass CDC实战:如何用sgdc约束文件解决跨时钟域报错(附常见错误排查)

本文详细介绍了如何使用SpyGlass CDC工具链中的sgdc约束文件解决跨时钟域(CDC)报错问题。从基础约束文件架构到复杂场景调试,涵盖了时钟域定义、复位信号约束、Waiver策略等关键技巧,并附有常见错误排查方法,帮助工程师高效处理CDC验证挑战。

loss4bartender的博客 1159

C++ PCL点云处理实战专栏

工业级点云处理技术学习资源,涵盖电力、建筑、隧道等领域的实战案例。内容分为三阶段:代码原理(算法认知)、动态库(项目验证)和完整代码(定制开发)。

weixin_45196569的博客 1134

poj3264Balanced Lineup(线段树)

poj3264Balanced Lineup Balanced Lineup Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 48911   Accepted: 22908 Case Time Limit: 2000MS Description

luckcircle的博客 350

【电路设计】SERDES与pcie

明确通信接口需要达到什么样的数据速率、信号完整性以及系统中各个部件的互相作用。2.

数字人生 4572

[kuangbin带你飞]专题七 线段树G - Balanced Lineup POJ - 3264

G - Balanced Lineup POJ - 3264 //#include<bits/stdc++.h> #include<cstdio> #include<algorithm> #include<iostream> using namespace std; const int M =100000+100; int sma[M&...

bjfu170203101的博客 176

基于TIA博途的一阶滞后滤波+中位值滤波+堆栈平均值滤波算法SCL语言程序(封装FB库)

基于TIA博途的一阶滞后滤波+中位值滤波+堆栈平均值滤波算法SCL语言程序(封装FB库)

Robot_PLC_HMI_Automation 2185

CMake入门教程【基础篇】在Windows、Linux上安装CMake

CMake如何下载与安装

小鱼酱的博客 2737

Balanced Lineup POJ - 3264

Balanced Lineup POJ - 3264 For the daily milking, Farmer John'sNcows (1 ≤N≤ 50,000) always line up in the same order. One day Farmer John decides to organize a game of Ultimate Frisbee with so...

Willen_的博客 267

Echarts - 去掉图表上的横线和竖线

效果图 默认效果: 变为如下图所示效果: 实现方法 官方配置文档:https://echarts.apache.org/zh/option.html#radar.splitLine 在 xAxis yAxis 配置中分别加入以下代码: splitLine: { show:false }

🏆 前端领域优质创作者 1万+

【RMQ_ST算法】POJ 3264 Balanced Lineup

RMQ 预处理部分: max_[i][j]=max(max_[i][j-1],max_[i + (1 << j-1)][j-1]); min_[i][j]=min(min_[i][j-1],min_[i + (1 << j-1)][j-1]); 释意: max_[ i ][ j ],从区间的第 i 的位置开始,长度为2 ^ j 的区间上的最大值。 我们要求区间的最大值,...

L_X_ 220

深度学习工具包 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")

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

POJ3264 Balanced Lineup

POJ3264 Balanced Lineup 这一题是ST表的模板题,但是我还是调了很久,主要是由于一个很经典的错误 很容易想到如下的方法: int fmaxx[50010][30],fminn[50010][30]; for (int j=1;j<=logg[n];j++){ for (int i=1;i<=n;i++){ fmaxx[i][j]=max(fmaxx[i]...

AlexTYJ的博客 209

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

【线段树 + 详细注释】北大 poj 3264 Balanced Lineup

/* THE PROGRAM IS MADE BY PYY */ /*----------------------------------------------------------------------------// Copyright (c) 2011 pan

panyanyany(飞雨幻沙) 1315

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

Balanced Lineup Poj3264

Balanced LineupTime Limit: 5000MS Memory Limit: 65536KTotal Submissions: 60228 Accepted: 28178Case Time Limit: 2000MSDescriptionFor the daily milking, Farmer John's N cows (1 ≤ N ≤ 50,000) always line...

xcantaloupe 200

poj 3264 Balanced Lineup

http://poj.org/problem?id=3264 Balanced Lineup Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 39375   Accepted: 18463 Case Time Limit: 2000MS Descr

大太阳 582

Balanced Lineup POJ-3264

模板题 //RMQ的两种实现方法 #include<cstdio> #include<iostream> #include<cmath> using namespace std; const int N=50010; int a[N], dpMax[N][30], dpMin[N][30]; //查询数组a的[l,r]区间的最值 int RMQ...

❂ 327

Balanced Lineup poj3264 线段树

Balanced Lineup poj3264 线段树 题意 一串数,求出某个区间的最大值和最小值之间的差 解题思路 使用线段树,来维护最大值和最小值,使用两个查询函数,一个查区间最大值,一个查区间最小值,然后做差就好了,基本上就是线段树模板题 代码实现 #include<cstdio> #include<cstring> #include<algorit...

weixin_30367169的博客 152

【RMQ】poj 3264 Balanced Lineup

RMQ 查询区间最值。 自然可以用线段树来做。 但对于序列值不改变的问题,查询可以用dp+位运算 其算法可以看作由区间dp演化而来,一般的数位dp需要用O(n^2)的时间复杂度来处理,预处理得到区间可以是任意的。 此时用功能的弱化来换时间。我们预处理只处理出区间 i->i+(2^j)-1 最值, 我们想得到 i->j 的最值可以由两个交叉的区间取最值来求(正因为求的是最值,所以区间

学无纸巾 2041
上一篇: HDU1011 Starship Troopers 树形DP
下一篇: HDU1054 Strategic Game 树形DP
Albafica
博客等级 码龄16年 98粉丝 359原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值