2019南昌网络邀请赛-I-Max Answer-线段树(RMQ)+ 单调栈

若依RuoYi文件上传漏洞实战:如何安全配置/profile/upload路径(附避坑指南) 本文深入解析若依RuoYi框架中/profile/upload路径的文件上传漏洞,提供详细的安全配置方案和实战指南。通过权限修正、输入验证强化和存储隔离等多层防御策略,有效防范未授权访问和恶意文件上传风险,保障系统安全。 阅读详情

题目传送门
在这里插入图片描述
思路:
先用单调栈算出每个a[i]可以作为区间最小值的区间的最左边和最右边。
如果a[i] > 0的话,直接整个区间的值都要,因为最小值为正数的区间的数全>0;
如果a[i] < 0 的话,可以从点前位置,可以向左向右暴力搜索最小值。(数据有点水,所以可以过)。
更好的做法是用线段树求维护每个点左边和,右边和的最大值。
但是线段树是用来求解 解可以进行区间合并的,最常见的就是区间的max,min,和sum.那么我们可以把这个问题转化为区间最值问题。假设要查寻的点为a[i],他的左边和右边分别为l,r.那么对左边,max(sum - pre[l-1] - suf[i])(sum为所有数的总和,pre,suf,分别为前缀和,后缀和。
这时,suf[i]是对于a[i]来说是固定的,所以建立树时,可以不用考虑。最后求出结果后,记得-suf[i]就可以了。右边同理。
也就是下面这个式子。

	LL lm = min(query_min(L[i]+1,i-1,1,0) - suf[i],1ll*0),rm = min(query_min(i+1,R[i]-1,1,1) - pre[i],1ll*0);

下面是线段树版的代码。

#include<bits/stdc++.h>
#define per(i,a,b) for(int i = (a);i <= (b);++i)
#define rep(i,a,b) for(int i = (a);i >= (b);--i)
#define INF 0x3f3f3f
using namespace std; 
typedef long long LL;
const int maxn = 5e5;
int n = 0,m = 0;
LL a[maxn+10];
LL pre[maxn+10],suf[maxn+10],sum = 0;
int L[maxn+10],R[maxn+10];
struct node{
	LL ma,mi;
	int l,r;
};
node tree[2][4*maxn+10];//0是往左边的,1是往右边的 
void build_tree(int l,int r,int root){
	tree[0][root].l = l,tree[0][root].r = r;
	tree[1][root].l = l,tree[1][root].r = r;
	
	if(l == r){
		tree[0][root].mi = tree[0][root].ma = sum - pre[l-1];
		tree[1][root].mi = tree[1][root].ma = sum - suf[l+1];
	}else{
		int mid = (l + r) >> 1;
		build_tree(l,mid,root<<1);
		build_tree(mid+1,r,root<<1|1);
		tree[0][root].mi = min(tree[0][root<<1].mi,tree[0][root<<1|1].mi);
		tree[0][root].ma = max(tree[0][root<<1].ma,tree[0][root<<1|1].ma);
		
		tree[1][root].mi = min(tree[1][root<<1].mi,tree[1][root<<1|1].mi);
		tree[1][root].ma = max(tree[1][root<<1].ma,tree[1][root<<1|1].ma);
	}
	return ;
}
LL query_max(int l,int r,int root,int id){
	if(tree[id][root].l > r || tree[id][root].r < l){
		return -1e18;
	}else if(l <= tree[id][root].l && r >= tree[id][root].r){
		return tree[id][root].ma;
	}else{
		return max(query_max(l,r,root<<1,id),query_max(l,r,root<<1|1,id));
	}
}
LL query_min(int l,int r,int root,int id){
	//if(l > r){
	//	return 0;
	//}
	if(tree[id][root].l > r || tree[id][root].r < l){
		return 1e18;
	}else if(l <= tree[id][root].l && r >= tree[id][root].r){
		return tree[id][root].mi;
	}else{
		return min(query_min(l,r,root<<1,id),query_min(l,r,root<<1|1,id));
	}
}

void Mo_stack(){
	stack<int> st;
	per(i,1,n){
		while(!st.empty() && a[i] <= a[st.top()]){
			st.pop();
		}
		if(st.empty()){
			L[i] = 0;
		}else{
			L[i] = st.top();
		}
		st.push(i);
	}
	
	while(!st.empty()){
		st.pop();
	}
	
	rep(i,n,1){
		while(!st.empty() && a[i] <= a[st.top()]){
			st.pop();
		}
		if(st.empty()){
			R[i] = n+1;
		}else{
			R[i] = st.top();
		}
		st.push(i);
	}
}
void init(){
	memset(pre,0,sizeof(pre)); memset(suf,0,sizeof(suf));
	sum = 0;	
	per(i,0,1){
		per(j,0,5e5*4){
			tree[i][j].mi = 1e18;	tree[i][j].ma = -1e18;
		}
	}	
}
int main(){
	while(~scanf("%d",&n)){
		init();
		per(i,1,n){
			scanf("%lld",&a[i]);
			pre[i] = pre[i-1] + a[i];
			sum += a[i];
		}
		rep(i,n,1){
			suf[i] = suf[i+1] + a[i];
		}
		Mo_stack();
		build_tree(1,n,1);
		LL maxv = -1e18;
		per(i,1,n){
			if(a[i] > 0){
				//LL lm = max(query_max(L[i]+1,i-1,1,0),1ll*0),rm = max(query_max(i+1,R[i]-1,1,1),1ll*0);
				//maxv = max(maxv,1ll*a[i]*(lm+a[i]+rm));
				maxv = max(maxv,1ll*a[i]*(pre[R[i]-1] - pre[L[i]]));//最小值为正数的区间的数全>0,所以区间内的数全要 
			
			}else if(a[i] < 0){
				//左边-suf[i],右边-pre[i]。 
				LL lm = min(query_min(L[i]+1,i-1,1,0) - suf[i],1ll*0),rm = min(query_min(i+1,R[i]-1,1,1) - pre[i],1ll*0);
				maxv = max(maxv,1ll*a[i]*(lm+a[i]+rm));
			}else{
				maxv = max(maxv,1ll*0);
			}
		}
		printf("%lld\n",maxv);
	}
	
	return 0;
}
/*
4
-1 -1 -1 -1
4
-3 1 -2 1
*/

下面是暴力版本的代码:

#include<bits/stdc++.h> 
using namespace std;
#define per(i,a,b) for(int i=(a);i<=(b);i++)
#define rep(i,a,b) for(int i=(a);i>=(b);i--)
#define pi acos(-1.0)
#define INF 0x3f3f3f3f
typedef long long LL;

const int maxn=5e5;
int n = 0,m = 0;
int a[maxn+10];
int L[maxn+10],R[maxn+10];
LL pre[maxn+10];
LL dp[maxn+10][20];
void Monotonous_stack(){
	stack<int> st;	
	per(i,1,n){
		while(!st.empty() && a[i] <= a[st.top()]){
			st.pop();
		}
		if(st.empty()){
			L[i] = 0;
		}else{
			L[i] = st.top();
		}
		st.push(i);
	}
	while(!st.empty()){
		st.pop();
	}
	
	rep(i,n,1){
		while(!st.empty() && a[i] <= a[st.top()]){
			st.pop();
		}
		if(st.empty()){
			R[i] = n+1;
		}else{
			R[i] = st.top();
		}
		st.push(i);
	}
}

void solve(){
	Monotonous_stack();

	LL maxv = -1e18;
	per(i,1,n){
		if(a[i] < 0){
			LL res = a[i];
			LL minv = 0,sum = 0;
			rep(j,i-1,L[i]+1){
				sum += a[j];
				minv = min(minv,sum);
			}
			res += minv;
			minv = 0,sum = 0;
			per(j,i+1,R[i]-1){
				sum += a[j];
				minv = min(minv,sum);
			}
			res += minv;
			maxv = max(maxv,res*a[i]);
		}else{
			maxv = max(maxv,(pre[R[i]-1] - pre[L[i]]) * a[i]);
		}
	}
	printf("%lld\n",maxv);
}
int main(){
	//std::ios::sync_with_stdio(false);
	//cin.tie(0) ;cout.tie(0);
	while(~scanf("%d",&n)){
		memset(pre,0,sizeof(pre));
		per(i,1,n){
			scanf("%d",&a[i]);
			pre[i] = a[i] + pre[i-1];
		} 
		solve();
	}
	
	return 0;
}
Android 14.0 开机广播接收慢广播延迟问题分析 在14.0的系统rom定制化开发中,在某些时候在接收开机广播的时候发现,过了一分钟才收到开机广播,接下来就需要分析下 开机广播的相关分发机制,来处理下相关问题 阅读详情

相关推荐

噪声整形与过采样实战:从N-bit ADC到DSM的SQNR优化指南

本文深入探讨了噪声整形与过采样技术在DSM(Delta-Sigma调制器)中的应用,重点分析了量化器位数(N)、滤波器阶数(L)和过采样率(OSR)对SQNR优化的影响。通过实战案例和参数协同优化策略,帮助工程师在音频处理和通信系统设计中实现更优的信号质量。

weixin_42561040的博客 339

2019ICPC南昌邀请赛总结

第一次参加全国性质的比赛,能和大佬们同台竞技真是太紧张了! 正式赛前一晚,做了好多梦,梦见打铁了3点多吓醒了QAQ 竟然能摸到一个铜,感觉也是很意外(运气成分居多),感觉全程瞎写。。。 一开始2分钟,队友看了一个签到L(真签到),然后我马上交上去了,AC,rank170+,赶紧看第二题,又发现了一道水题K,简单贪心sort一下求和就好,1A,看了看rank150+。还行,估摸了一下铜线300...

永远鲜红の幼月的博客 1211

verilog CORDIC对数运算

verilog CORDIC对数运算

m0_64355812的博客 1735

2019南昌icpc网络赛 I. Max answer (单调栈)

Alice has a magic array. She suggests that the value of a interval is equal to the sum of the values in the interval, multiplied by the smallest value in the interval. Now she is planning to find the ...

Stormjing的博客 522

基于MYD-YT153与AD7616的16通道高速ADC采集系统实战指南

在嵌入式系统与工业数据采集领域,模拟信号采集是连接物理世界与数字系统的关键技术。其核心原理是通过模数转换器(ADC)将连续的模拟电压信号转换为离散的数字码值,供处理器处理。这项技术的价值在于实现了对温度、压力、振动等关键物理量的精确感知与数字化,是工业自动化、设备监测、科学实验等场景的基石。本文聚焦于**多通道**、**高精度**采集这一常见需求,深入剖析如何利用全志T153处理器的LocalBus并行总线接口,高效驱动ADI的16位、16通道同步采样ADC芯片AD7616,构建一个稳定可靠的高速数据采集系

weixin_30335353的博客 443

使用Power Apps实现SharePoint Online列表的下拉菜单的级联选择

在SharePoint列表中添加数据的时候,下拉菜单的级联选择一直是一个非常实用的功能,尤其是有很多数据的情况,级联选择可以根据上一层的选择,自动过滤下一层的选择,方便用户查找和选择准确的信息。一个最常用的情景是选择供应商的地区和国家,例如有三个列表,一个是供应商所在的大洲,一个是国家,一个是供应商。当用户选择州的时候,会自动列出属于这个州的国家。避免用户迷失在大量的数据中。 这里展示一下如何在...

shrenk的专栏 7809

2019南昌邀请赛网络赛 I.Max answer

单调栈维护左边和右边第一个大于它的位置 用ST表维护区间前缀和的最大值和最小值 当前点小于0的时候就是后半部分Smin−前半部分Smax后半部分Smin-前半部分Smax后半部分Smin−前半部分Smax 大于0的时候就是后半部分Smax−前半部分Smin后半部分Smax-前半部分Smin后半部分Smax−前半部分Smin #include <bits/stdc++.h> using ...

indiewar's blogs(wust_lzl) 440

Unity游戏Google Play闪退?可能是这个隐藏设置惹的祸(附完整解决方案)

本文深度解析Unity游戏在Google Play上出现闪退的疑难问题,指出其根源可能在于Google Play后台的“应用完整性”设置与游戏原生库的冲突。文章提供了从崩溃日志分析、本地与线上版本对比测试,到调整Unity构建设置、审查第三方插件以及优化分发包配置的系统性排查与根治方案,帮助开发者彻底解决这一隐蔽问题。

weixin_29213827的博客 234

2019南昌邀请赛网络赛 I. Max answer

这题麻烦之处在于有负数,对于每一段连续的正数,我们假设当前最小的数字是a[i],那么所能得到最大的value就是包含i的最大区间且最小值是a[i],直接用单调栈维护每一个数字所统治(以他为最小值)的最大区间范围。 负数的话,对于一个很小的负数,这个区间我们希望他的和越小越好,那么乘起来最大值就会越大,所以我们要想怎么找到包含这个点的和最小的区间,一开始我想用two point ,后来越想越怪。最...

binarycopycode 590

Python XML 转 JSON,XML 转字典

今天我们将学习如何在 Python 中将 XML 转换为 JSON 和 XML 转换为字典。我们可以使用 Python 的xmltodict模块来读取 XML 文件并将其转换为字典或 JSON 数据。我们还可以在大型 XML 文件上进行流式处理,并将其转换为字典。在进入编码部分之前,让我们首先了解为什么需要进行 XML 转换。

rubys_的专栏 2501

Python 爬虫实战:爬虫与 ECharts 结合 —— 前端可视化展示

本文介绍了爬虫技术与ECharts可视化结合的完整实现流程。首先使用Python爬取京东商品数据(价格、评价数等),通过BeautifulSoup解析和pandas处理转换为JSON格式。然后构建前端页面,利用ECharts实现价格分布柱状图、价格-评价数散点图和店铺占比饼图三种可视化效果。文章详细解析了爬虫数据提取、格式转换和前端图表配置等关键技术点,并提供了完整的代码示例。最后提出了基于API接口、数据库存储等扩展方向,为数据采集到可视化展示提供了完整的解决方案。

2503_91057718的博客 631

2019年南昌网络赛 I题 Max answer (单调栈 + 线段树)

Max answer Alice has a magic array. She suggests that the value of a interval is equal to the sum of the values in the interval, multiplied by the smallest value in the ...

forever_131514的博客 307

【微服务】Java 对接飞书多维表格使用详解

Java 对接飞书多维表格使用详解

congge_study的博客 1万+

2019南昌网络赛 I Max Answer(单调栈)

题目链接: https://nanti.jisuanke.com/t/38228 题意: 给你一个nnn个整数的序列,定义一个区间[l,r][l,r][l,r]的值为min[l,r]∗∑i=lra[i]min_{[l,r]}\ast\sum_{i=l}^ra[i]min[l,r]​∗∑i=lr​a[i],让你求最大的这个值; 分析: 枚举序列中的每个数a[i]a[i]a[i],求以a[i]a[i]...

梧桐 313

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

2019 icpc南昌邀请赛网络赛 I Max answer 暴力/单调栈/线段树

题目链接 题意: 给n个数,每段区间的和等于的区间内最小值乘以区间内每个数的和的最大值,求最大的区间值 思路: 难点在于有负数,如果只有正数,单调栈板子就可以处理,(太菜了,比赛的时候不会处理负数,虽然听说别人用单调栈或线段树或单调栈加线段树过了这个题,但是自己毫无思路) 然后下来以后看了别人的代码,只学会了暴力的方法; 计算每个数i以i为最小值的区间的最左值和最右值,注意如果i是负数...

暖心的博客 430

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

icpc南昌邀请赛网络赛 I-Max answer

题目链接:I-Max answer 题目大意:给出n个数,求得一个区间使得该区间最小的数乘上该区间所有数的和最大,即,输出该结果。注意:a[i]可为负。 思路:若a[i]全为正,可参考poj2796,单调栈的经典应用。具体来考虑单调栈的作用,它可以求出以每个a[i]为最小值时所对应的最大区间(l,r),区间和用前缀和计算即可:sum[i]-sum[j],若a[i]为正,显然直接维护答案即可; ...

风花雪月流残败局 343

efm32 入门.pdf

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

2019南昌ICPC网络赛 I Max answer【单调栈+ST表】

Alice has a magic array. She suggests that the value of a interval is equal to the sum of the values in the interval, multiplied by the smallest value in the interval. Now she is planning to find the...

NoobPlayer_llke的博客 1278

The Preliminary Contest for ICPC China Nanchang 南昌网络赛 A H I J 线段树,主席树,lca(注意这才是正常的lca,不要用以前的模板拉!)

其它一些是队友做的,我就写自己做的这几个吧 A. PERFECT NUMBER PROBLEM Write a program to output the first 55 perfect numbers. A perfect number is defined to be a positive integer where the sum of its positive integer divis...

天翼之城的博客 984

2019南昌邀请赛网络赛 I. Max answer(ST算法+单调栈)

【题面】 Max answer 【题解】 题意:定义一个区间的价值为区间和*区间最小值,给定一个序列,求子区间的最大价值。 思路:先用ST表维护区间前缀和最大最小值,然后用单调栈跑出以每个值为最小值的最大左边界和右边界,最后对每个值分成负数和正数讨论取可行区间内的最小或最大值。当为负值时,在区间[i,最大右边界]查询最小前缀和,在区间[最大左边界-1,i-1]查询最大前缀和,这样相减能得到...

菜鸡成长史 470

I. Max answer(ICPC南昌邀请赛 I题目)

The Preliminary Contest for ICPC China Nanchang National Invitational and International Silk-Road Programming Contest. 一开始想着线段树,用线段树搞了半天,一拍脑瓜,发现自己白费功夫被自己蠢到了哈哈哈 后来想到对每一个数都找一个合适的区间,再求和相乘就能得到包括这个元素的区间最大值...

weixin_44090305的博客 639

2019南昌网络邀请赛 Max answer (单调栈)

Max answer 问答问题反馈 只看题面 11.63% 3000ms 262144K Alice has a magic array. She suggests that the value of a interval is equal to the sum of the values in the interval, multiplied by the smallest va...

1999 285

2019南昌网络赛 I. Max answer(DP或者单调栈+思维)

Alice has a magic array. She suggests that the value of a interval is equal to the sum of the values in the interval, multiplied by the smallest value in the interval. Now she is planning to find the...

pxlsdz的博客 383

南昌邀请赛 - I Max answer(单调栈 + 线段树)

题面: 这题如果a[i] > 0,则是一道经典的单调栈,如果针对a[i]大于0的情况不太清楚的话,可以参考我写的单调栈其他的题目,现在我们重点来讨论a[i] < 0的情况。 如果a[i]小于零,则应该使得包含a[i]的区间和最小,即找到1~i区间上最大的前缀和lmax,和i-n区间上最小的前缀和rmin,然后两者相减得到最小的区间前缀和,很容易联想到用线段树来维护区间前缀的最值,这是...

weixin_43533544的博客 252

2019 南昌网络赛 I. Max answer

这题是poj2796的变形,用线段树来维护每个负数的对应的最小区间和 #include<iostream> #include<stack> #include<stdio.h> using namespace std; #define ls rt<<1 #define rs rt<<1|1 #define ll long long co...

SEIZE THE DAY 288

I. Max answer 2019南昌邀请赛网络赛

2019南昌邀请赛网络赛 The Preliminary Contest for ICPC China Nanchang National Invitational and International Silk-Road Programming Contest I. Max answer 题意:求出一个区间和*区间和中的最小值 这个值最大的时候。 思路:瞎搞搞出来了,讲道理,这次是我个...

DeathYmz的博客 706

【2019南昌邀请赛网络赛I:】Max Answer(st表+单调栈(新模版)+分析)

题目地址:https://nanti.jisuanke.com/t/38228 题意: 给出数字序列,定义一个区间内的value值是这个区间所有数之和*这个区间的最小数,求对于这个数字序列,最大的value值 解题思路: 本题为https://blog.csdn.net/Cassie_zkq/article/details/89792443的进阶题。 对正数和负数分开处理。 ...

Cassie_zkq的博客 334
上一篇: Educational Codeforces Round 64 (Rated for Div. 2) - B. Ugly Pairs - 构造法
下一篇: Comet OJ - Contest #3子序列子序列子序列...
Mavis code
博客等级 码龄9年 13粉丝 147原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值