GUPTA MECHANICAL

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

Friday, 8 July 2022

[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 ij and k on a coordinate line is called beautiful if i<j<k and kid.

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

Solution Click Below:-  👉CLICK HERE👈
👇👇👇👇👇


  • add a point;
  • 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 (1q,d2105) — 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 a1,a2,,aq (1ai2105) 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.
Output

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

No comments:

Post a Comment