2019亚洲区域赛徐州网络赛 E XKC's basketball team 线段树

模拟电子技术课设-压控信号发生器 正弦波产生电路的目的就是使电路产生一定频率和幅度的正弦波,我们一般在放大电路中引入正反馈,并创造条件,使其产生稳定可靠的振荡。由于图2.3-1所示电路中存在RC电路和积分电路两个延迟环节,在实用电路中,将它们“合二为一”,即去掉方波发生电路中的RC回路,使积分运算电路即作为延迟环节,又作为方变三角波电路,滯回比较器和积分运算电路的输出互为另一个电路的输入。接着对各单元电路的工作原理进行了分析,由直流稳压电源电路提供所需电压,文氏振荡器产生正弦波,滞回比较器产生方波,滞回比较器与积分器连接产生三角波。 阅读详情

https://nanti.jisuanke.com/t/41387
XKC , the captain of the basketball team , is directing a train of nn team members. He makes all members stand in a row , and numbers them 1 \cdots n1⋯n from left to right.

The ability of the ii-th person is w_iwi, and if there is a guy whose ability is not less than w_i+mw i +m stands on his right , he will become angry. It means that the jj-th person will make the ii-th person angry if j>ij>i and w_j \ge w_i+mwj ≥wi +m.

We define the anger of the ii-th person as the number of people between him and the person , who makes him angry and the distance from him is the longest in those people. If there is no one who makes him angry , his anger is -1−1 .

Please calculate the anger of every team member .

Input
The first line contains two integers nn and m(2\leq n\leq 5*10^5, 0\leq m \leq 10^9)m(2≤n≤5∗10
5 ,0≤m≤10 9).

The following line contain nn integers w_1…w_n(0\leq w_i \leq 10^9)w
1 …w n
(0≤wi≤109) .

Output
A row of nn integers separated by spaces , representing the anger of every member .

样例输入 复制
6 1
3 4 5 6 2 10
样例输出 复制
4 3 2 1 0 -1

题目大意:第 i i i元素的愤怒值定义为:在 i i i右侧的所有满足 a [ j ] > = a [ i ] + m a[j]>=a[i]+m a[j]>=a[i]+m中最大的 j − i − 1 j-i-1 ji1,若不存在这样的数则值为 − 1 -1 1。输出每个元素的愤怒值。

思路:也算是签到题吧。用线段树维护区间最大值。那么要查询的其实就是 [ i + 1 , n ] [i+1,n] [i+1,n]内满足 a [ j ] > = a [ i ] + m a[j]>=a[i]+m a[j]>=a[i]+m的最大的 j j j,因此考虑优先查询右子树,最后返回下标即可。

#include<iostream>
#include<cstdio>
using namespace std;

const int maxn=5e5+5;

struct node
{
	int l,r,MAX;
}tree[maxn<<2];

int n,m;
int a[maxn];

void build(int i,int l,int r)
{
	tree[i].l=l,tree[i].r=r;
	if(l==r)
	{
		scanf("%d",&tree[i].MAX);
		a[l]=tree[i].MAX;
		return ;
	}
	int mid=l+r>>1;
	build(i<<1,l,mid);
	build(i<<1|1,mid+1,r);
	tree[i].MAX=max(tree[i<<1].MAX,tree[i<<1|1].MAX);
}

int query(int i,int l,int r,int v)
{
	if(tree[i].l==tree[i].r)
		return tree[i].l;
	int mid=tree[i].l+tree[i].r>>1;
	if(tree[i<<1|1].MAX>=v)
		return query(i<<1|1,l,r,v);
	else if(l<=mid&&tree[i<<1].MAX>=v)
		return query(i<<1,l,r,v);
	else
		return -1;
}

int main()
{
	scanf("%d%d",&n,&m);
	build(1,1,n);
	int ans;
	for(int i=1;i<=n;i++)
	{
		if(i==n)
			ans=-1;
		else
			ans=query(1,i+1,n,a[i]+m);
		if(ans!=-1)
			ans-=i+1;
		printf("%d%c",ans,i==n?'\n':' ');
	}
	return 0;
}

使用单片机和电流互感器对非正弦周期电流有效值测定 使用单片机和电流互感器,利用一种高速采样的方法来进行有效值测定 阅读详情

相关推荐

ASProxy64.dll导致jetbrains家的IDE都无法打开。

摘要:在Windows11系统中,JetBrains IDE无法启动,报错指向ASProxy64.dll文件。该第三方DLL被注入到JVM原生层,导致内存访问冲突(错误代码0xc0000005)。经排查发现此文件来自Astrill软件。解决方案为卸载Astrill后重启电脑,问题得以解决。该案例表明第三方DLL注入可能影响IDE正常运行,卸载相关软件是最直接的解决方法。(149字)

猿小白的博客 877

The Preliminary Contest for ICPC Asia Xuzhou 2019 徐州网络 D Carneginon

Carneginon was a chic bard. But when he was young, he was frivolous and had joined many gangs. Recently, Caneginon was to be crowned, because the king was shocked by his poems and decided to award him...

日拱一卒,功不唐捐 2867

【win10】win 10 电脑喇叭音频显示红叉的处理方法

目录 一、报错情况 二、“音频服务未运行”解决方法 三、“未插入扬声器或耳机”解决方法 一、报错情况 (1)当电脑的扬声器喇叭图标上带有红X符号,提示“音频服务未运行”时: (2)小喇叭上面有红叉,显示“未插入扬声器或耳机”时: 二、“音频服务未运行”解决方法 (1)开始菜单搜索“服务”: (2)没有启动的点击“启动”,已启动的点击“重新启动”: (3)继续,右...

顾三殇 —— 博客空间(软件测试) 17万+

2019徐州网络 - XKC's basketball team

题目链接:XKC’s basketball team 比较简单的做法就是线段树维护最大值,然后二分区间找最远的那一个即可。 AC代码: #pragma GCC optimize(2) #include<bits/stdc++.h> //#define int long long using namespace std; const int N=5e5+10; int n,m,a[N...

青烟绕指柔的博客 708

2019亚洲区域徐州网络 M Longest subsequence 思维

https://nanti.jisuanke.com/t/41395 String is a very useful thing and a subsequence of the same string is equally important. Now you have a string ss with length nn and a string tt with length mm. Find...

xiji333的博客 722

2019亚洲区域徐州网络 D Carneginon KMP算法

https://nanti.jisuanke.com/t/41386 Carneginon was a chic bard. But when he was young, he was frivolous and had joined many gangs. Recently, Caneginon was to be crowned, because the king was shocked by...

xiji333的博客 562

The Preliminary Contest for ICPC Asia Xuzhou 2019 E. XKC's basketball team线段树查询)

The Preliminary Contest for ICPC Asia Xuzhou 2019 E. XKC’s basketball team 题意 给 n 个数,和一个 m,对于每个数 i ,找右边最远的满足 j >= m 的 j。 输出两个数中间的数字个数。 分析 n 2e5,很明显要找一个 n log n 的算法,也就是对于每个数查询做到 log n。 自然想到线段树 。对于每个...

Stormjing的博客 470

2019徐州网络A,B,C,D,E,G,I,K,M

A 中国剩余定理,I 树状数组解决偏序问题,G回文树 A. Who is better? 题打表发现是一个斐波拉契数的博弈,是斐波拉契数的就是先手必胜。 题目链接:https://nanti.jisuanke.com/t/41383 这里出题人强行套了一个中国剩余定理。。。 #include <bits/stdc++.h> using namespace std; ...

ccsu_deer 1428

网络补题----XKC's basketball team

明若清溪天下绝歌 缱绻成说,不知该在哪处着墨;一生情深怎奈何世事 徒留斑驳,只一念痴恋成奢。 XKC , the captain of the basketball team , is directing a train ofnnteam members. He makes all members stand in a row , and numbers them1 \cdots n1⋯n...

0k-ok 627

2019icpc徐州网络E.XKC's basketball team(权值线段树

https://nanti.jisuanke.com/t/41387 题意:给你一个n,m,n个人都有一个Wi权值,问你每个人的右面最远的一个Wj大于等于Wi+m的位置与这个人的位置中间有多少人 (j>i,Wj>=Wi+m); 题解:在每个 i 的右面找大于等于Wi+m的最远位置,用权值线段树倒着维护下标,查询一次,更新一次。偶对了,离散化。 细节:1.倒着做,是因为正着一次全...

gml1999的博客 242

2019icpc 徐州网络 E.XKC's basketball team(线段树)

XKC , the captain of the basketball team , is directing a train of nn team members. He makes all members stand in a row , and numbers them 1⋯n from left to right. The ability of the i-th person is w_i...

weixin_44014982的博客 326

2019徐州网络 G题 (回文树 节点回文串不同的字符个数)

传送门 题意: 对于给定的字符串,求每个子回文串中不同的字符个数之和。 思路: 回文树。 cnt[i]cnt[i]cnt[i]表示节点 iii 的回文串个数。 sum[i]sum[i]sum[i]表示节点 iii 表示的回文串的不同字符个数。 在构造回文树的时候判断当前插入的字符 ccc 在其匹配位置 curcurcur 处是否出现过, 在继承curcurcur的答案的基础上进行更新。 #incl...

WayJasy的博客 354

2019 徐州网络 XKC's basketball team(蔡徐坤的篮球队)(线段树维护区间最值)

XKC , the captain of the basketball team , is directing a train ofnnteam members. He makes all members stand in a row , and numbers them1 \cdots n1⋯nfrom left to right. 蔡徐坤,是一个篮球队的队长,正在指导对n个队员的训练...

Untersee-boot XXI 710

XKC's basketball team线段树

线段树的模板 //这个是区间的最大值。 #define maxn 1000005 #define mod 1000000007 int a[maxn]; struct node { int l,r,ma; }tree[maxn*4]; void build(int l,int r,int p) //表示当前节点的标号,也就是根节点的编号。 { t...

qq_2992427261 237

Codeforces 107B Basketball Team 简单概率

题目链接:点击打开链接 题意: 给定n m h 表示有m个部门,有个人现在在部门h 下面m个数字表示每个部门的人数。(包括他自己) 在这些人中随机挑选n个人,问挑出的人中存在和这个人同部门的概率是多少。 这个人一定在挑出的n个人中。 反向思考。答案是 1 - 不可能概率 不可能概率 = C(n-1, sum-1-a[h]) / C(n-1, sum-1) 发现2个组合数的分母部分

九野的博客 1914

ACM-ICPC 2018 徐州网络(solve7/11)

题目链接:https://www.jisuanke.com/contest/1557?view=challenges A题 题意:给你2^k个面具,然后n个人,要求挨着的2个人二进制之后不能互补。问你有多少不同的方案数 思想:对于这2^k个数最多就两个数是互补的,所以考虑下第一个数有2^k种选择,第二个2^k-1种,假如倒数第二个跟第一个不一样,那么最后一个由2^k-2种选择,假如一样的话,...

passer__的博客 1340

icpc国际大学生程序设计竞全国邀请徐州站比总结

  怎么说呢,这场比我和窑子的发挥算是稳定的,但也只能说完成了我们该做的事情,世冬那出了点问题,但也是意料之中,一是感冒影响,二是其实只要是个比都会出点状况的,能稳定应对各种状况才是向前奋进的基础。总之拿下了acm生涯中的首铜,虽说世冬觉得有错失银牌的感觉,但是明显还是实力不到,心态也做不到那么稳定。  先说说题目吧,第一天热身A题签到题,我和窑子配合,很快找出了公式,出来了,然后他俩就开始...

m0_37772713的博客 594

E:XKC's basketball team(The Preliminary Contest for ICPC Asia Xuzhou 2019

XKC , the captain of the basketball team , is directing a train ofnnteam members. He makes all members stand in a row , and numbers them1 \cdots n1⋯nfrom left to right. The ability of theii-th p...

ZCY的博客 347

Xuzhou网络19 E【线段树

XKC’s basketball team 传送门。 题意: 第一行两个数nnn mmm (2≤n≤5∗105,0≤m≤109)(2\leq n\leq 5*10^5, 0\leq m \leq 10^9)(2≤n≤5∗105,0≤m≤109) 第二行nnn个数的序列 w1..wn(0≤wi≤109)w_1..w_n(0\leq w_i \leq 10^9)w1​..wn​(0≤wi​≤109...

zhmeng 182

2019 icpc 徐州区域

第一次打比,经验不足,只知道上来的读题出了点问题,不过问题不是很大,做出了两道签到题,第三题打表,结果打错了,出现了精度丢失问题,与铜牌无缘了,而且不是很会用 linux 下的编译器,要不然也不用手动记录了,不过也增长了不少经验,现在准备补题了。 ...

百般回首曾经的相遇,留下的只是一缕残忆 841

acm-icpc-徐州

https://www.jisuanke.com/contest/1557?view=challenges i-Characters with Hash 签到题,简单模拟 注意0删掉前导0还是0 ac: #include&lt;bits/stdc++.h&gt; #define maxn 1000007 using namespace std; char ctr,str[maxn];...

wangtao的博客 352

CF 107B Basketball Team [排列组合]

类似高中的盒子取球,关键理解题意 问题转化为,从m个盒子中取n个球,在取了h盒中的一个球的条件下,h盒还取了别的球的概率 可以这样求得 sum表示m个盒子中总共有多少个球 从sum-1中取n-1个球的情况数是总情况数 减去从sum-m[h]取n-1个球的情况数 即是要求的情况数 #include #include #include #include #includ

Rainto的专栏 900

GJB 3677B-2023 装备检验验收要求.rar

GJB 3677B-2023 装备检验验收要求

甘肃省兰州市高三数学一诊试题 文(扫描版,无答案) 试题.doc

甘肃省兰州市高三数学一诊试题 文(扫描版,无答案) 试题.doc

上一篇: 2019亚洲区域赛徐州网络赛 D Carneginon KMP算法
下一篇: 2019亚洲区域赛徐州网络赛 K Center map+贪心
csu_xiji
博客等级 码龄9年 181粉丝 1147原创
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值