## GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

# [Solution] Points Codeforces Solution | Codeforces 2022

F. Points
time limit per test
6.5 seconds
memory limit per test
512 megabytes
input
standard input
output
standard output

A triple of points $i$$j$ and $k$ on a coordinate line is called beautiful if $i and $k-i\le d$.

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

Solution Click Below:-  👉
👇👇👇👇👇

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

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

Grass Field Codeforces Solution

Permutation Codeforces Solution

Schedule Management Codeforces Solution

Permutation Restoration Codeforces Solution

Text Editor Codeforces Solution

Points Codeforces Solution

The second line contains $q$ integers ${a}_{1},{a}_{2},\dots ,{a}_{q}$ ($1\le {a}_{i}\le 2\cdot {10}^{5}$) denoting the queries. The integer ${a}_{i}$ denotes the $i$-th query in the following way:

• if the point ${a}_{i}$ belongs to the set, remove it; otherwise, add it;
• after adding or removing the point, print the number of beautiful triples.
Output

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