How can I make this program faster ?

Правка en1, от ghoshsai5000, 2017-04-08 17:11:12

I have tried to solve the problem of finding k-interesting pairs [here].(http://mirror.codeforces.com/contest/769/submission/26220768)

My solution is quadratic O(n^2). If it is run on the sequence of numbers given, then n = 10^5 at most. I have followed the trick of the editorial and built an array of the frequencies of each element. This happens in O(n) time, with n = 10^5, at most

And have then applied the quadratic time algorithm on the frequency array so now n = 10^4. However, this isn't enough to get past the time limit.

What are further optimizations I can perform ?

Теги complexity optimization

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en3 Английский ghoshsai5000 2017-04-14 17:57:29 95
en2 Английский ghoshsai5000 2017-04-09 07:23:06 773
en1 Английский ghoshsai5000 2017-04-08 17:11:12 619 Initial revision (published)