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

Автор krishrb2517_, история, 11 месяцев назад, По-английски

https://mirror.codeforces.com/contest/1906/problem/E

This is the link to the problem E of 2023-2024 ICPC, Asia Jakarta Regional Contest (Online Mirror, Unrated, ICPC Rules, Teams Preferred) , can anyone help me in understanding the intuition and logic behind the dp approach of this problem. I cannot seem to grasp the logic behind the problem.

Any suggestion/idea maybe helpful too!!

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

»
11 месяцев назад, # |
Rev. 2   Проголосовать: нравится +12 Проголосовать: не нравится

I am not good in Explaining but still I'm trying, Hope you will get it.

Let's consider Arrays A and B and resultant array C (merged array).

The element from the first array will be appended to C until the element of the second array is larger, For example lets take first Testcase

C= {3 1 4 5 2 6}.

If first element belong to the array A then until next greater element of first element should belong to the same array i.e. {3, 1} should belong to the same array,

moving forward the element {4} would belong to any array, {5,2} belong to any array and {6} belong to any array.

Observe that we are partitioning the elements until its next greater element.

Taking another example C={3, 1, 2, 5, 4, 7, 6, 8}

partitions are {3, 1, 2}, {5, 4}, {7,6}, {8}

Now we have to divide these partitions in two arrays without changing the order.

To divide these partitions we have to use knapsack and mark the partitions that can make two arrays of equal size. Also check that these partitions can divide array equally or not.

In the second example, first and fourth partition should belong to the same array and remaining belong to the another array i.e.

A={3,1,2,8}

B={5,4,7,6}

For reference you can see this code https://mirror.codeforces.com/contest/1906/submission/236794036

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

    Actually thanks bro , you explained it pretty well, I have got some ideas now and understood your approach, will try working on it a bit and then try implementing there, and will take help from your code