ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1613. For Fans of Statistics

Another way to get AC
Posted by standy 24 Jul 2012 22:59
You should use a SQRT-decomposition. Let BLOCK = sqrt(N) In kth element of the decomposition you should store hash_set containing numbers from k * BLOCK to (k + 1) * BLOCK.
Re: Another way to get AC
Posted by Tornike Mandzulashvili 21 Aug 2012 14:59
i am getting time limit on test 13 , with sqrt-decomposition.
Another way to solve this task
Posted by quieteodium 29 May 2013 18:44
You can solve this task using binary search.
Sort all numbers with their indexes.
Now if we get query L R X, we use binary search to find all X numbers between
our numbers. If we found X in binary search, check it's index, if it's >= l and <=r then
answer for query is 1. If such number wasn't found in binary search, answer for query is 0.
Re: Another way to solve this task
Posted by alexey saybel 7 Apr 2016 19:06
> if it's >= l and <=r then answer for query is 1

it isn't enough 'cause you can have several cities with the same population and simple binary search finds just one of them

3
666 666 666
1
1 1 666

has to answer 1