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

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

Hi Codeforces Community, A problem came in DE Shaw OA more than 10 days ago , Here is the problem, I guess some kind of sorting is involved but am not able to figure out how to do it. I think it is a very good problem and these problems have become quite standard in online assessments. So if you guys can throw some light onto the problem that would be very helpful. If possible please do provide code for the problem.

Question-

Given two arrays A and B of size n. We are given q queries of the form x y. The answer to a given query is (A[ i ]+B[ i ]) where A[ i ] >=x && B[ i ] >=y && (A[ i ] +B[ i ]) is minimum for 0=< i < n. If answer for a query is not possible then print -1 for that query.

`1=< n,q <= 10^5`
`1=< A[i],B[i] <=10^9`
`Eg-`
`n=5 q=4`             
`6 4 8 9 15`
`7 7 2 9 6`
`4 6 -> 11(4,7)`
`2 8 -> 18(9,9)`
`14 9 -> -1`
`7 1 -> 10(8,2)`

Полный текст и комментарии »

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