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

Автор Gi4Th4ng_Di77_NLUN, история, 4 часа назад, По-английски

Hi guys, Im having a problem about the number, but I haven't solved. PLS Help me. The problem is: Given an array a (length 2e5) of positive integer numbers. Chose a subarray from L to R (1 < L <= R < n) Delete all the number from Al -> Ar. Find the min average of the left nums.

Sample INPUT 5 5 1 7 8 2 Sample OUTPUT 2.667

2 subtask: n <= 1e3 and n <= 1e5 I solve the first one, but not the latter.

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

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

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

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

Use kadane algorithm to find the maximum sum subarray in the new array b, where b[i] = a[i] — avg(a).

Corner case is when all elements of array are the same in which case you can remove all n elements.

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

I think we can use Binary Search here. Kadane mightn't work in here.

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

What do you mean by average of the left nums

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

    Sample INPUT 5 5 1 7 8 2 Sample OUTPUT 2.667 L = 4, R = 5 => OUTPUT is 13/4=3.25. Why not?

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

Binary Search ???