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 1439. Battle with You-Know-Who

O(M * log N) in 0.421s with C# and without Binary Search!!
Posted by Leonid (SLenik) Andrievskiy 21 Aug 2011 03:58
Using Binary Indexed Tree (aka Fenwick tree) and standart System.Dictionary (dictionary bsaed on hashing).

Hint: you do not need binary search over heap!
If you're familiar with Fenwick tree's structure, you can write your own function, which'll find the smallest index in fenwick's tree with given sum.