Блог пользователя aravind.nujella

Автор aravind.nujella, история, 4 часа назад, По-английски

Assume a codeforces like platform where there are $$$n$$$ users and their ratings vary over time $$$[0, T]$$$. Now given an interval $$$[l,r]$$$, we would like to find top k profiles which had highest delta in that interval.

Is it possible to answer this query without iterating over $$$n$$$ interval sums? For example we can get $$$O(n\log(n)\log(T))$$$ by maintaing fenwick tree per user and sorting the list of interval sums.

Edit: Added requirement to avoid looping over $$$n$$$ users..

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
3 часа назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

Cant you just use prefix sums of each profile. Then use PriorityQueue and in total you need to precompute in O(T*N) and each query works for O(N+K).

  • »
    »
    3 часа назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Thats true. What I should have asked for is to reduce $$$n$$$ factor in the query since I do not want to iterate over list of users.

    • »
      »
      »
      3 часа назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      You can store it in dp[l,r] and do query in O(K) but your space complexity will be very very large. I think there is more smart way, but its first what comes to mind.

      • »
        »
        »
        »
        3 часа назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        Yeah. That DP is not feasible because $$$T$$$ can be quite big.

»
3 часа назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by aravind.nujella (previous revision, new revision, compare).