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

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

Suppose we partition the elements of an array b into any number k of non-empty subarrays S1,S2,…,Sk , where k is an arbitrary positive integer. Define the score of b as the maximum value of MEX(S1)+MEX(S2)+…+MEX(Sk) over all possible partitions of b for any integer k n <= 2e5

continous subarrays not for subsequence for [0 0 1 1] ans is 3

how can i calculate score .

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

»
23 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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

»
23 месяца назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

I misread the problem

»
23 месяца назад, скрыть # |
← Rev. 3  
Проголосовать: нравится +7 Проголосовать: не нравится

The solution is:

Make a frequency table, store the frequency of all elements in the array, make a prefix (min) array of that frequency table, the answer is the sum of all elements in the prefix min array.

Code

A nice problem that uses the same idea : 2030E - MEXimize the Score

»
23 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

This looks like DP where dp[i] is the score of the prefix until i but I didn't solve yet

»
23 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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

»
23 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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

»
6 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Did you got the solution?