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

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

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.

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

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

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).