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

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

Hi Everyone!

I hope you're all having a great day!

Last week, I participated in NAQ 2023. After the contest, I've been trying to upsolve Problem J (Platform Placing), but I keep getting WA on test case 6.

Here is a link to my code.

And here is a high-level summary of my code (problemB()):

  1. Read the input. Add (1e18) and (-1e18) to the set of platforms to represent extra space for the first and last platforms.

  2. Sort the array.

  3. Iterate through and expand the current platform as much as possible.

  4. Add the length to our result and record the increased size of the platform.

This is similar to the greedy approach that the contest authors offer, but for some reason, it continues to fail! If anyone could help me out with what is going wrong here, it would be very appreciated.

Thanks!

Simon

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

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

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

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

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

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

Why are front and back defined differently?

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

    Front = distance to the next platform. Back = distance to the previous platform.

    I subtract s/2.0 from the front to ensure that there is enough space for the next platform.

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

When the answer is large you output it in scientific notation because you're printing double, multiply everything by 2 and use long long instead.