650iq's blog

By 650iq, history, 14 months ago, In English

There are N towers arranged in a single line. You want to rearrange all the towers.

Given an array H of size N, where Hi denotes the height of tower i. You can rearrange this array in whatever way you like.

Beauty is defined as follows:

If j is the position of the tower i in the final arrangement, you add Hi*abs(i-j) to the Beauty.

Your task is to find the maximum Beauty you can achieve, after rearranging the towers.

I could only come with bitmask dp solution but here N is 10^3 so it won't work.

  • Vote: I like it
  • 0
  • Vote: I do not like it

| Write comment?
»
14 months ago, # |
Rev. 4   Vote: I like it 0 Vote: I do not like it

It's abc163_e.

  • There is an editorial in English.
  • However, note that the problem may be quite hard for you (it's rated $$$2037$$$ on AtCoder).