CF1701F.Points

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

A triple of points ii , jj and kk on a coordinate line is called beautiful if i<j<ki < j < k and kidk - i \le d .

You are given a set of points on a coordinate line, initially empty. You have to process queries of three types:

  • add a point;
  • remove a point;
  • calculate the number of beautiful triples consisting of points belonging to the set.

输入格式

The first line contains two integers qq and dd ( 1q,d21051 \le q, d \le 2 \cdot 10^5 ) — the number of queries and the parameter for defining if a triple is beautiful, respectively.

The second line contains qq integers a1,a2,,aqa_1, a_2, \dots, a_q ( 1ai21051 \le a_i \le 2 \cdot 10^5 ) denoting the queries. The integer aia_i denotes the ii -th query in the following way:

  • if the point aia_i belongs to the set, remove it; otherwise, add it;
  • after adding or removing the point, print the number of beautiful triples.

输出格式

For each query, print one integer — the number of beautiful triples after processing the respective query.

输入输出样例

  • 输入#1

    7 5
    8 5 3 2 1 5 6

    输出#1

    0
    0
    1
    2
    5
    1
    5
首页