Tufurama CodeForces - 961E (树状数组 )

MATLAB与图像处理(一):图像中结构张量的求法(Structure Tensor) 1.结构张量的作用:       能够区分图像中的平坦区域,边缘,角点; 2.图像中的结构张量的定义    1)是一个矩阵;    2)与图像的水平,垂直梯度有关,定义如下: 在MATLAB中,可以用如下语句求解:[Ix,Iy]=gradient(Image); 3)求出结构张量矩阵的行列式,和迹(矩阵对角线之和)   行列式:K=det(E);   迹:   阅读详情

 

One day Polycarp decided to rewatch his absolute favourite episode of well-known TV series "Tufurama". He was pretty surprised when he got results only for season 7 episode 3 with his search query of "Watch Tufurama season 3 episode 7 online full hd free". This got Polycarp confused — what if he decides to rewatch the entire series someday and won't be able to find the right episodes to watch? Polycarp now wants to count the number of times he will be forced to search for an episode using some different method.

TV series have n seasons (numbered 1 through n), the i-th season has ai episodes (numbered 1 through ai). Polycarp thinks that if for some pair of integers x and y(x < y) exist both season x episode y and season y episode x then one of these search queries will include the wrong results. Help Polycarp to calculate the number of such pairs!

Input

The first line contains one integer n (1  ≤ n  ≤  2·105) — the number of seasons.

The second line contains n integers separated by space a1, a2, ..., an (1 ≤ ai ≤ 109)— number of episodes in each season.

Output

Print one integer — the number of pairs x and y (x < y) such that there exist both season x episode y and season y episode x.

Examples

Input

5
1 2 3 4 5

Output

0

Input

3
8 12 7

Output

3

Input

3
3 2 1

Output

2

Note

Possible pairs in the second example:

  1. x = 1, y = 2 (season 1 episode 2  season 2 episode 1);
  2. x = 2, y = 3 (season 2 episode 3  season 3 episode 2);
  3. x = 1, y = 3 (season 1 episode 3  season 3 episode 1).

In the third example:

  1. x = 1, y = 2 (season 1 episode 2  season 2 episode 1);
  2. x = 1, y = 3 (season 1 episode 3  season 3 episode 1).

 

题意:给出一个n,下面一行 共有n个位置,每个位置上一个值a[i],让你找 共有多少对 x,y 满足下面条件 a[x]>=y&&a[y]>=x&&x<y;n的范围2·105   你要是两层 for 循环的话一定超时, 所以你一定要采取一些 结构来解决这个问题;你想想树状数组,可以知道从 1~n之间的 数的 谁出现过或者最大值、和 等等,1~n的数谁出现过 是最主要的,可以利用插入过后 就立刻查询这个特点 ;  例如数状数组求 逆序数,逆序数 满足 a[x]>a[y]&& y>x; 这个意思就是找y这个位置 之前有几个比自己大的数, 求逆序数,要是给出的n个数 数值比较大,那么就应该先进行离散化,离散化后的序列,除了值变了,但每个位置之间的对应大小关系时不变的, 就让离散化后的这个序列,进行挨个插入添加到数状数组中去,每插入一个就进行查询一次,看看比它小或等于的数,已经插入了几个了,让当前位置 减去 比它小或等于的数 的个数,不就是前面比它大的数的个数吗;

 

看看能不能 从 用树状数组求逆序数中 得出来的经验, 数状数组 中存的是位置; 当前位置有没有出现过,还有就是在树状数组中进行插入时,是按照特定的符合题目要求的序列插入的,看看我们能不能构造出来一个这样的序列呢?

因为它要满足三个条件,看看能不能在插入之前都 已经满足一个条件了?这个构造真的需要自己好好理解理解

因为数状数组求的是 小于等于自己的数已经插入了几个; 如 要是插入的是x,找a[y] 之前出来了几个就行了,满足a[y]>=x这个条件,

那么插入之前能不能 让他们先满足了 a[x] >= y 这个条件呢?请看代码:完美 巧妙的让之满足了这个条件;  

先定一个vector 数组,让v[i][] 中存位置,而当前位置的值为 i ,如i大于n就存到v[n][]中,因为这个位置上的值大于n,而位置范围是1~n,没有大于n位置上的值与之对应,所以就存到v[n][]中就行了;然后枚举 y,从n到1枚举,这样就满足了a[x]>=y这个条件,在利用数树状数组求 前面插入的有几个小于等于a[y]的 数就行了,还有就是注意 y>x 这个条件,代码中那个min(i-1,  a[y]),就是 控制y>x&&找已经插入的 小于等于a[y]的个数 代码中有解释:

代码:


// 树状数组中插入的还是下标;
 
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#include<vector> 
#define Max 2*100000+10
 
int c[Max],a[Max];
vector<int >v[Max];
// v[i][] 中存 给出的数列中数值为i的 位置; 
int n;
 
void init()
{
	int i,j;
	for(i = 0;i<=n;i++)
		v[i].clear();
}
int lowbit(int x)
{
	return x&-x;
}
 
void add(int x,int val)
{
	while(x<=n)
	{
		c[x] += val;
		x += lowbit(x);
	}
}
 
int ssum(int x)
{
	int res = 0;
	while(x>0)
	{
		res +=c[x];
		x -= lowbit(x);
	}
	
	return res;
}
 
int main()
{
	while(~scanf("%d",&n))
	{
		init();
		int i,j;
		
		for(i = 1;i<=n;i++)   // v[][]
 		{
			scanf("%d",&a[i]);
			if(a[i]<=n) v[a[i]].push_back(i);
			else v[n].push_back(i);
		}
		
		memset(c,0,sizeof(c));
		
		long long  res = 0;
		// 枚举y, 
		for(i = n;i>=1;i--)    // 从后往前,v[i][] 中的值为位置,而这个位置上a数组中的值为i,
		 // 设v[i][] 这里面位置为x ,从而a[x]>=i(本来是等于i,而i是从n到1递减的,所以先这样说)
		 //  下面只需找a[i]>=x 的个数就行了,从后往前是为了是为了 找到全部的;
		 // 下面的 min(i-1,a[i]),因为是枚举的y  找的小于y的位置中是不是已经插入过;
		 // 所以要用min(y-1,a[y]);
		{
			for(j = 0;j<v[i].size();j++)   //这一步 是为了让 a[x]>=y;
				add(v[i][j],1);
			res += ssum(min(i-1,a[i])); 
			// 枚举的y,所以要找前面的 i-1是一个限制(为什不是i,i的话就把本身了给算进去了)
			// 还得 满足 a[y]>=x, 所以 又于a[i]比较;  
		}
		printf("%lld\n",res);
	}
	return 0;
} 

 

 

形状记忆合金热机械本构模型的ABAQUS子程序实现与Fortran\_ABAQUS编程实践 本文详细介绍了如何使用ABAQUS子程序实现形状记忆合金的热机械本构模型,并通过Fortran_ABAQUS进行编程实践。我们首先介绍了问题的背景和目标,然后讲解了如何在Fortran_ABAQUS子程序中实现热变形模型、应力应变关系和相变模型,最后进行了ABAQUS模拟,并分析了模拟结果。希望通过本文的讲解,能让大家更深入理解ABAQUS子程序以及Fortran的使用,也希望能对大家在进行相关学习或研究工作时提供一些帮助。 阅读详情

相关推荐

MQL5教程 01 MT5有关EA的操作、MetaEditor 工具栏主要功能

MQL5教程 01 MT5有关EA的操作、MetaEditor 工具栏主要功能

weixin_42830015的博客 4017

Codeforces 1635 F. Closest Pair —— 树状数组,思维,有一丶丶东西

This way 题意: 给你长度为n的数组x(x[i]<x[i+1])和w,对于一对i,j,定义他们的val为∣xi−xj∣∗(wi+wj)|x_i-x_j|*(w_i+w_j)∣xi​−xj​∣∗(wi​+wj​)。 每次给你l,r,问你[l,r]中val最小为多少 题解: 第一次挑战28的题目,说实话还是不够难,感觉只有25左右难度。 一开始我想到的是笛卡尔树,但是不太对劲,因为它并不是区间这种东西。 接下来我想到的是斜率优化,然后我就开始写式子…然后就写不下去了。 由于点i一定会找w比它小的

天翼之城的博客 1545

无人机测绘航线生成算法

JavaScript开发和测试无人机测绘航线的自动生成方法,设计可行,算法可靠

ly1302116的专栏 5249

CodeForces 799C Fountains(树状数组)

树状数组 把满二叉树的形状稍微改变一下,变成下面的图形。 用C[i]代表子树的叶子结点的权值之和。以求和举例 1=(001) C[1]=A[1]; 2=(010) C[2]=A[1]+A[2]; 3=(011) C[3]=A[3]; 4=(100) C[4]=A[1]+A[2]+A[3]+A[4]; 5=(101) C[5]=A[5]; 6=(1...

H4ppyD0g的博客 548

AI论文写作工具对比:千笔AI与文途AI实战测评

AI写作工具正逐步改变学术写作生态,其核心原理是通过自然语言处理技术实现文本生成与优化。这类工具的技术价值在于提升写作效率,降低学术入门门槛,特别适合文献综述、研究方法设计等标准化环节。在实际应用中,不同工具各有侧重:千笔AI擅长结构化写作与量化分析,文途AI则聚焦质性研究与思维拓展。本科生使用这些AI论文助手时,需特别注意学术伦理边界,所有生成内容必须经过严格人工校验。合理运用AI工具能有效缓解论文写作中的文献处理、方法表述等痛点,但核心学术思维仍需研究者自主构建。

weixin_34023982的博客 465

STM32 无线充电接收端硬件设计:从 LC 谐振到 PWM 控制的 5 大关键电路解析

本文深入解析了基于STM32的无线充电接收端硬件设计,重点探讨了LC谐振倍压整流、INA282电流采样、IR2104S半桥驱动、超级电容保护及STM32最小系统等5大关键电路。针对超级电容的恒功率充电需求,详细介绍了PID控制算法优化及PCB设计实战要点,帮助工程师提升无线充电系统的效率和可靠性。

weixin_31774841的博客 393

codeforces 1023 D Array Restoration (树状数组)

题面 题意 有一个长度为n的序列,你可以进行 q 次修改,第i次修改将区间 [l,r] 的数修改成 i ,涉及的 q次修改必须要覆盖区间中的每个数,q 次修改之后,将这个序列中的某些数变为0,得到一个新的序列(就是输入的序列),问你能不能通过这个新的序列求出一个变0之前的合法序列 题解 要求的这个字符串肯定是要有q的,因为q是最后一次修改,修改之后肯定有q,那么就要求输入的这个序列要么包含q,要么包含0(我们就可以将0变为q),如果输入的序列既没有q也没0,那么一定输出NO 要想有合法序列

qq_44791484的博客 322

别再用Python卷了!用Matlab的Deep Learning Toolbox快速上手U-Net图像分割(附完整数据集处理代码)

本文介绍了如何使用Matlab的Deep Learning Toolbox快速上手U-Net图像分割,包括数据准备、网络构建、训练监控和模型应用等完整流程。Matlab的高度集成工具链和图形化界面为图像分割任务提供了更快捷、直观的解决方案,特别适合研究人员和工程师快速实现原型验证。

weixin_29927965的博客 389

CodeForces - 961E(树状数组)

链接:CodeForces - 961E题意:给出一个序列A,下标1-N,求满足(1) x &lt; y (2) a[x] &gt;= y (3) a[y] &gt;= x的数对有多少个。题解:求数对个数,考虑到用树状数组。但只用树状数组却无法同时满足条件(2)(3),故先用vector满足条件(3),再用树状数组。vector[min(i - 1, a[i])].push_back(i);即在满...

鬼沐冢 1241

TSN新技术,让您的设备网络“更实时、更确定、更安全”

近日,工业和信息化部发布了2022年第23号公告,批准发布行业标准YD/T 4134-2022《工业互联网时间敏感网络需求及场景》。该标准是国内首个时间敏感网络(TSN)技术标准,标志着我国TSN技术标准体系建设迈出了坚实的一步,对构建工业互联网网络标准体系具有重要意义。TSN源于Time-Sensitive Networking的缩写,中文译名为时间敏感网络,因其具备的确定性和微秒级交互特性,受到了对实时性要求较高的工业控制领域的关注。TSN与工业数智化。

创龙,嵌入式一体化解决方案商 777

【系统架构设计师】二十六、论文写作要点

论文写作概述:时间所需120分钟;题目可四选一,必有一题考察软件架构,总有一款适合你;考察形式是机试(开心,再也不用担心字丑了),约2500字。

帅次的博客 4609

CodeForces 597C 树状数组 dp

CodeForces 597C #include #include #include #define ll long long using namespace std; const ll maxn = 1e5; ll d[maxn+10]; ll dp[15][maxn+10]; ll a[maxn+10]; ll n,k; ll lowbit(ll x){ return x&(-x); }

育 364

SAP BOM (物料清单) 详解

BOM(Bill of Materials,物料清单)是制造业和生产管理中的一个核心概念。它列出了生产某种产品所需的所有原材料、零部件和子组件的详细信息。在SAP系统中,BOM管理是为了帮助企业在生产过程中更高效地管理物料需求、库存以及生产成本。BOM不仅包括物料的数量和单位,还详细描述了每个物料的规格、标准和在产品中的位置。

我小时候很黑的博客 4274

【CodeForces 961E --- Tufurama】树状数组

【CodeForces 961E --- Tufurama】树状数组 题目来源:点击进入【CodeForces 961E — Tufurama】 Description One day Polycarp decided to rewatch his absolute favourite episode of well-known TV series “Tufurama”. He was prett...

来日浅谈的博客 594

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

InTheHand.Net.Personal+BlueTooth4,蓝牙开发

项目中有蓝牙开发的必备dll,现在网上相关的文档博客不少,有的说的多有的说少,但是却很少有这两个dll,分享一下。

CodeForces - 961E - Tufurama 树状数组

E. Tufuramatime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day Polycarp decided to rewatch his absolute favourite episode of well-known TV ser...

a302549450的博客 582

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

Codeforces961 E. Tufurama(树状数组)

题意: 给定长度为n的序列a 问有多少个数对(x,y),满足: x<y a[x]>=y a[y]>=x 数据范围:n<=2e5 解法: 三个条件: x<y a[x]>=y a[y]>=x 其实前两个可以合并: x<y<=a[x] x<=a[y] 即对于每个x,计算[x,a[x]]范围内 满足x<=a[y]的y的数量 每次都暴力...

zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz 311

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

Codeforces 961E - Tufurama 【树状数组】

Codeforces 961E - Tufurama 【树状数组】 Educational Codeforces Round 41 (Rated for Div. 2) One day Polycarp decided to rewatch his absolute favourite episode of well-known TV series "Tufurama". He was pretty surprised when he got results only for season 7 episod

Dust_heart的博客 1609

CodeForces - 961E Tufurama(树状数组)

TufuramaOne day Polycarp decided to rewatch his absolute favourite episode of well-known TV series "Tufurama". He was pretty surprised when he got results only for season 7 episode 3 with his search q...

nka_kun的博客 492

Codeforces_961E_Tufurama(树状数组or线段树)

传送门 题意:有一部电视剧有n季,每一季有ai集。问有多少对i,j存在第i季第j集也同时存在第j季第i集。 思路:核心问题还是统计对于第i季,你要统计第i行(存在多少数量,要大于i)。 线段树的维护相对而言比较暴力,树状数组的话,一开始全是1,一旦某个数过小,就会导致不构成贡献,移除就好。 tips:对于这样的题目,可以首先思考排序,这样可以省去一维操作。 线段树: #includ...

yyy_3y的博客 409

Codeforces Round 961

Codeforces Round 961

青少年趣味编程 666

Tufurama CodeForces - 961E

Tufurama CodeForces - 961E 题意:有一部电视剧有n季,每一季有ai集。问有多少对i,j存在第i季第j集也同时存在第j季第i集。 思路:核心问题还是统计对于第i季,你要统计第i行(存在多少数量,要大于i)。线段树的维护相对而言比较暴力,树状数组的话,一开始全是1,一旦某个数过小,就会导致不构成贡献,移除就好。 线段树 #include<...

weixin_30556161的博客 86

Educational Codeforces Round 41 (Rated for Div. 2) _E. Tufurama

大家如果有能力的话,可以看一下当时比赛页面中的题解,当然了题解大部分都会是英文的,比如这个题的首先打开这道题:http://codeforces.com/contest/961/problem/E,然后我们在下面可以看到这个东西:那么这个就是题解了,点进去就可以看到这次题的所有题解以及正确的程序,当然Codeforces上的所有程序以及测试样例也都是公开的,大家也可以在一下大神们的程序,看一下能不...

A_Bo的博客 564

Tufurama CodeForces - 961E (cdq分治)

题面 One day Polycarp decided to rewatch his absolute favourite episode of well-known TV series "Tufurama". He was pretty surprised when he got results only for season 7 episode 3 with his search q...

weixin_30375427的博客 269

codeforces961E、Tufurama (主席树)

                                                                                                    E. Tufurama time limit per test 2 seconds memory limit per test 256 megabytes input standard i...

Amove 376

codeforces 961E Tufurama

题目链接:http://codeforces.com/contest/961/problem/E 题意:给你n个数ai,(n<=2e5,1<=ai<=1e9)然后问你在这n个数中,有多少对i,j(i<j)满足ai>=j&&aj>=i。输出对数即可 分析:首先我们知道对于满足要求的i,j,我们需要满足ai>j和aj>i。然后我们枚举...

weixin_34024034的博客 119

从零评估FrontStep v0.5.2:前端开源工具部署与工作流接入

前端工程化中,工具链的选择直接影响开发效率。面对Hacker News上涌现的开源项目,如何快速评估和集成成为开发者常见需求。本文以FrontStep v0.5.2为例,介绍一套从环境准备(Node.js、npm)到本地部署、功能验证、CI接入的完整流程。通过CLI命令、npm scripts以及HTTP封装等方式,可将这类前端工具无缝融入现有工作流。同时也针对0.x版本常见的依赖安装、端口占用、版本兼容等问题给出了排查方案。无论你是前端工程师还是技术负责人,都能借鉴这套方法论,理性评估社区新工具的价值。

weixin_33970449的博客 394
上一篇: Ultra-QuickSort POJ - 2299 (数状数组 线段树 归并排序 求逆序数)
下一篇: Pair Of Lines CodeForces - 961D (数学 直线 上的几何)
obsorb_knowledge
博客等级 码龄9年 38粉丝 213原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址