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

Автор AJ__20, история, 3 года назад, По-английски

I was given a question with integer array A of size N, And asked to find answer for Q queries. Each query consists of (L, R, Min, Max). One need to find the minimum sum in the given range(L, R) with atleast 'Min' element and atmost 'Max' elements should be in the minimum sum. Constraints : 1 <= N <= 1e5, 1 <= Q <= 1e5, 1 <= Testcases <= 1e5. I tried brute force approach and got TLE. I searched the internet for the optimal approach and couldn't find the answer, so could anyone explain how to approach this problem? Edit : All the queries are available to function as a parameter when the function is invoked.

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

»
3 года назад, скрыть # |
 
Проголосовать: нравится +4 Проголосовать: не нравится

Two questions:

  1. Do you mean that we need to choose at least $$$min$$$ elements and at most $$$max$$$ elements from the segment $$$[l, r]$$$?
  2. Can the array contain negative elements?