CF773E.Blog Post Rating

NOI/NOI+/CTSC

通过率:0%

时间限制:4.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

It's well-known that blog posts are an important part of Codeforces platform. Every blog post has a global characteristic changing over time — its community rating. A newly created blog post's community rating is 0. Codeforces users may visit the blog post page and rate it, changing its community rating by +1 or -1.

Consider the following model of Codeforces users' behavior. The i-th user has his own estimated blog post rating denoted by an integer a__i. When a user visits a blog post page, he compares his estimated blog post rating to its community rating. If his estimated rating is higher, he rates the blog post with +1 (thus, the blog post's community rating increases by 1). If his estimated rating is lower, he rates the blog post with -1 (decreasing its community rating by 1). If the estimated rating and the community rating are equal, user doesn't rate the blog post at all (in this case we'll say that user rates the blog post for 0). In any case, after this procedure user closes the blog post page and never opens it again.

Consider a newly created blog post with the initial community rating of 0. For each of n Codeforces users, numbered from 1 to n, his estimated blog post rating a__i is known.

For each k from 1 to n, inclusive, the following question is asked. Let users with indices from 1 to k, in some order, visit the blog post page, rate the blog post and close the page. Each user opens the blog post only after the previous user closes it. What could be the maximum possible community rating of the blog post after these k visits?

众所周知,博客文章是 Codeforces 平台的重要组成部分。每篇博客文章都具有一个随时间变化的全局特征——其社区评分(community rating)。一篇新创建的博客文章的初始社区评分为 0。Codeforces 用户可以访问该博客文章页面并为其评分,使其社区评分增加或减少 1。

考虑如下 Codeforces 用户行为模型:第 ii 位用户对其所评价博客文章的估计评分为一个整数 aia_i。当一位用户访问博客文章页面时,他会将自己的估计评分与该文章当前的社区评分进行比较:

  • 若其估计评分更高,则该用户给予 +1+1 评分(即博客文章的社区评分增加 1);
  • 若其估计评分更低,则该用户给予 −1-1 评分(即博客文章的社区评分减少 1);
  • 若估计评分与社区评分相等,则该用户不进行任何评分(此时称该用户评分为 0)。

无论何种情况,完成上述操作后,该用户即关闭博客文章页面,且此后不再打开。

现考虑一篇新创建的博客文章,其初始社区评分为 0。已知 nn 位 Codeforces 用户(编号从 1 到 nn)各自对这篇博客文章的估计评分 aia_i。

对每个 kk(1≤k≤n1 \le k \le n),提出如下问题:
设编号为 11 至 kk 的用户以某种顺序依次访问该博客文章页面、进行评分并关闭页面(每位用户仅在前一位用户关闭页面后才打开页面)。问:经过这 kk 次访问后,博客文章的社区评分可能达到的最大值是多少?

输入格式

The first line contains a single integer n (1 ≤ n ≤ 5·105) — the number of Codeforces users.

The second line contains n integers _a_1, _a_2, ..., a__n ( - 5·105 ≤ a__i ≤ 5·105) — estimated blog post ratings for users in order from 1 to n.

第一行包含一个整数 nn(1≤n≤5⋅1051 \leq n \leq 5 \cdot 10^5)—— Codeforces 用户的数量。

第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \ldots, a_n(−5⋅105≤ai≤5⋅105-5 \cdot 10^5 \leq a_i \leq 5 \cdot 10^5)—— 按照用户编号从 1 到 nn 的顺序给出的博客文章评分估计值。

输出格式

For each k from 1 to n, output a single integer equal to the maximum possible community rating of the blog post after users with indices from 1 to k, in some order, visit the blog post page, rate the blog post, and close the page.

对于每个从 11 到 nn 的 kk,输出一个整数,表示在编号为 11 至 kk 的用户(以某种顺序)访问博客文章页面、对该文章评分并关闭页面之后,该博客文章所能达到的最大可能社区评分。

输入输出样例

  • 输入#1

    4
    2 0 2 2

    输出#1

    1
    1
    2
    2
  • 输入#2

    7
    2 -3 -2 5 0 -3 1

    输出#2

    1
    0
    -1
    0
    1
    1
    2

输入解题思路,AI测评打分。不知道怎么写?

首页