How to implement multiset in java efficiently?

Revision en1, by YocyCraft, 2023-01-05 12:05:55

In 1718C - Tonya and Burenka-179 I inplemented a solution with intended complexity (which was O(n*log(n)*PrimeFactorCount(n))), which need a multiset to update the possible answer between queries, and answer the max element of the multiset for each query. But since there's no multiset in java, I had to simulate a multiset by a TreeMap, which caused TLE (my submission:188008030)

I looked at other java solution for this problem and no one got AC. Is this problem unsolvable for java or there's better implementation for multiset?

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English YocyCraft 2023-01-05 15:17:45 2 Tiny change: '1718C] I inplemented ' -> '1718C] I implemented '
en1 English YocyCraft 2023-01-05 12:05:55 579 Initial revision (published)