Need some help regarding recent Div(1+2)E

Revision en2, by NTU_ICPC, 2025-04-08 14:20:04

Firstly, apologies since I honestly don't know how to type latex. Anyways, most of us probably took part in the most recent Div(1+2) round, and E was kinda a bloodbath.

I read the editorial solution, and it seemed that many people used some form of fenwick to solve it. I definitely don't understand how, but I'm trying to use fft now..

The only difficulty now would be finding the coefficients for a fixed k. I could do so when at least one number <= k was present in the array. However it seems like I'm not so sure how it'd go if none were present. So for now, it seems my code will give the right answer if 0 was present in the initial array, and wrong one if it wasn't.

My current idea is that you have to iterate over >=k -1's. However that seems inefficient. Anyone could suggest a hint for me? Thanks.

I included my implementation here. The case I would need to complete is around line 150.

https://mirror.codeforces.com/contest/2084/problem/E

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English NTU_ICPC 2025-04-08 14:20:04 168
en1 English NTU_ICPC 2025-04-08 14:18:54 876 Initial revision (published)