欢迎光临散文网 会员登陆 & 注册

CF 1760C - Advantage

2023-07-03 10:02 作者:您是打尖儿还是住店呢  | 我要投稿

There are n participants in a competition, participant i having a strength of si.

Every participant wonders how much of an advantage they have over the other best participant. In other words, each participant i wants to know the difference between si and sj, where j is the strongest participant in the competition, not counting i (a difference can be negative).

So, they ask you for your help! For each i (1≤i≤n) output the ifference between si and the maximum strength of any participant other than participant i.

-------------------------------------------------

一场比赛有 n 名参赛者,参赛者 i 的实力为 si。

每个参与者都想知道他们比其他最好的参与者有多少优势。 换句话说,每个参与者i都想知道si和sj之间的差异,其中j是比赛中最强的参与者,不包括i(差异可以为负)。

所以,他们请求你的帮助! 对于每个 i (1≤i≤n) 输出 si 与除参与者 i 之外的任何参与者的最大强度之间的差异。

------------------

每个选手想知道自己跟其他最厉害的选手的差距,这时候可以用2个变量去存储目前遇到的最大值,跟第2大的值。然后存储在当前数组中,这样还不占额外的空间。

(我一开始是用的优先队列去存储的,但是超时了。就参考其他人的代码了)

下面是代码:


CF 1760C - Advantage的评论 (共 条)

分享到微博请遵守国家法律