vivekcrux's blog

By vivekcrux, history, 5 years ago, In English

Link to the problem:- Equal Average
I have tried to solve this question by rearranging the array in a way that a sequence of length k gets repeated so that the average of all k length subsequences is same. Now I need to place the elements in their appropriate positions and check whether any such sequence is possible or not. For that I have used priority_queue. The elements with greater occurrences will be placed first at separations of k.
Here's my submission, but it's giving wa, I don't know where I'm getting wrong. Any help would be appreciated.

  • Vote: I like it
  • +12
  • Vote: I do not like it

| Write comment?
»
5 years ago, # |
  Vote: I like it +13 Vote: I do not like it

1 7 3 2 1 1 2 1 1 2

  • »
    »
    5 years ago, # ^ |
      Vote: I like it +7 Vote: I do not like it

    0118 999 881 999 119 725 3

  • »
    »
    5 years ago, # ^ |
      Vote: I like it +6 Vote: I do not like it

    Ok, I got it, placing elements just on the basis of the count of their occurrences will not work.
    Can you suggest any other approach?. Thanks