← Questions
Count arithmetic triples in a multiset under add and remove queries
0
I was asked this
No reports yet. Sign in to say where you were asked it.
Start with an empty multiset and a fixed difference d. Each query either adds one copy of x or removes every copy of x. After each query, report how many triples of elements (counting copies separately) can be ordered as x, x + d, x + 2d. Keep a count per value and update the running total by only the triples that the changed value takes part in, instead of recounting.
No official answer yet. Write yours on the right and run it.
Nothing published yet.
Sign in to submit your code; every attempt is kept here.
Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding
