CVOTE - Editorial

lower_bound behaves like binary search and has complexity O(log N).
O(N) equivalent for basic types is


```
lower_bound(int* L, int* R, int val) {
    int* i = L;
    for (; i < R && *i < val; ++i);
    return i;
}
```

It works correctly only if array is sorted.

Refer to this for exact equivalent raw code:
http://www.cplusplus.com/reference/algorithm/lower_bound/

Will you please refer me to any book or online stuff where I can learn more about STL and functions common in practice in C++, along with their explanations?

http://www.cplusplus.com/reference

Actually I always google function_name C++ reference and appear on the corresponding page at this site.

Thanks Anton, you are the man. One ctrl+z wreaked havoc for me :frowning:

While checking this code at my PC Iā€™m getting a correct answer.

But why it is rejected by this website machine?

Please indent your code properly. It is very hard to follow it.

Also I see some double loops like for each vote you traverse the list of all chefs to find the proper one.

Such solution will get TLE after you fix the bug that leads to WA.

Hi

You discussed that Hashing approach can also be used - well I tried using the simple djb2 string hashing with a lot of different constants/table sizes but always got WA because collisions were not handled. Could you please tell how to go about solving this using hashtables in C++ ?

Thanks

Which compiler?