Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Блог пользователя bruj_kosh

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

Can someone give more insights on this ICPC-19 online round problem . I know it requires LIS and prefix sum but I can't develop the idea.

Before writing this blog I have searched for it's answer in ICPC India Online Round 2019 Discussion blog on Codeforces but no one has explained the idea there, thus I have no source to understand it ...

Thanx, regards.

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

»
4 года назад, # |
  Проголосовать: нравится +12 Проголосовать: не нравится

The problem is asking us to partition the array into multiple subarrays, such that the sum of each subarray is positive.

Consider a partitioning a[1...p1], a[p1 + 1... p2], a[p2 + 1 ... p3], etc. where p[i] is the last index of the ith subarray.

Clearly, we can rewrite this using prefix sums,

pref[p1] - pref[0], pref[p2] - pref[p1], pref[p3] - pref[p2] , etc.

clearly, all of these terms need to be positive, meaning that pref[p(i)] > pref[p(i - 1)]

This means we need to find and restore an increasing subsequence of length k on an array of prefix sums, which can be done with a simple modification to the normal LIS

Hope this helps, :p

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится +20 Проголосовать: не нравится

    I get it totally now, I really want to thank u from heart to take ur time in this.....

    After ur explanation it seems quite a lot easy to code ... actually I was a lot confused after I saw submissions of other Teams on Codechef.

    Again that just means a lot :)

    Thanx, regards.