|  | 
|  | 
| вернуться в форум | Brute force;-) Послано Katy  21 июл 2006 03:52I know that this problem could be solved using sorting and something like that - my friends do so but don't share code, I don't know how.I used brute force (= the easiest way) and i got AC 0.281    330 KB at C++
Re: Brute force;-) You can use structure Heap or Interval Tree ( because the value of the elements is rather small ).Heap : O(NlogM)
 Interval tree : O(N log(Max_Value) ).
 Interval tree also can give you the k-th smallest value in log (Max_value).
Re: Brute force;-) My solution is O(N).No subject Послано Mewtwo  20 мар 2016 19:04I know that this problem could be solved using sorting and something like that - my friends do so but don't share code, I don't know how.I used brute force (= the easiest way) and i got AC 0.281    330 KB at C++
 Yes... and with little bit of optimization, one can get AC in half of that time... :) Edited by author 20.03.2016 19:06 | 
 | 
|