Some questions about iterator and n log n solution

  algorithm, c++, data-structures

My code is described as below:
I am solving a problem which requires n log n time complexity
I am storing a large number of elements into a multiset and I think it cost O(logn) time but distance function cost O(n) time so my code exceed the time limit.
Do you know any of other data structure and find the index of an element in that so that overall time complexity is O(nlogn)? Please give me, Thanks you very much ( I am VietNamese, sorry for my poor english)

Multiset  St;
loop -> (st.insert(number); ...
multiset <long long> :: iterator it; 
it = lower_bound( value) 
cout << distance (st.begin(), it); 

Source: Windows Questions C++

LEAVE A COMMENT