Need help with SPOJ problem FREQ2

Правка en1, от harsha_1_2, 2020-04-19 13:09:35

I am solving problems on mo's algorithm and came across this problem FREQ2. I am using an array (inv_freq) where inv_freq[x] stores the no of distinct elements having frequency x along with a dynamically updated square root decomposed array of this to find the max frequency. I believe its complexity is O((Q+N)*sqrt(N)). My solution is timing out. Can someone help with a better way to find this maximum?

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский harsha_1_2 2020-04-23 15:40:16 294
en1 Английский harsha_1_2 2020-04-19 13:09:35 529 Initial revision (published)