CF1701F.Points
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
A triple of points i , j and k on a coordinate line is called beautiful if i<j<k and k−i≤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 q and d ( 1≤q,d≤2⋅105 ) — the number of queries and the parameter for defining if a triple is beautiful, respectively.
The second line contains q integers a1,a2,…,aq ( 1≤ai≤2⋅105 ) denoting the queries. The integer ai denotes the i -th query in the following way:
- if the point ai 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