CF773E.Blog Post Rating

普及/提高-

通过率:0%

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 ii -th user has his own estimated blog post rating denoted by an integer aia_{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 nn Codeforces users, numbered from 1 to nn , his estimated blog post rating aia_{i} is known.

For each kk from 1 to nn , inclusive, the following question is asked. Let users with indices from 1 to kk , 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 kk visits?

输入格式

The first line contains a single integer nn ( 1<=n<=51051<=n<=5·10^{5} ) — the number of Codeforces users.

The second line contains nn integers a1,a2,...,ana_{1},a_{2},...,a_{n} ( 5105<=ai<=5105-5·10^{5}<=a_{i}<=5·10^{5} ) — estimated blog post ratings for users in order from 1 to nn .

输出格式

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

输入输出样例

  • 输入#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
    
首页