helloIamCristiano's blog

By helloIamCristiano, history, 20 months ago, In English

We have 2 arrays $$$A$$$ and $$$B$$$ of length $$$n$$$ each. We are required to pick $$$k$$$ elements from both the arrays say $$$A_{i_{1}}, A_{i_{2}}, ... A_{i_{k}}$$$ and $$$B_{i_{1}}, B_{i_{2}}, ... B_{i_{k}}$$$ such that the sum $$$A_{i_{1}} + A_{i_{2}} + ... + A_{i_{k}} > \lfloor{\frac{S_{A}}{2}}\rfloor$$$ and $$$B_{i_{1}} + B_{i_{2}} + ... + B_{i_{k}} > \lfloor{\frac{S_{B}}{2}}\rfloor$$$. Here $$$S_{A}$$$ and $$$S_{B}$$$ denote the sum of the arrays A and B respectively.$$$\newline$$$ We also want to print the indices we have chosen, if such a choice is possible.$$$\newline$$$ Also, pay attention to the fact that we are picking elements from $$$B$$$ with the same indices $$${i_{1}, i_{2}, ... , i_{k}}$$$ that we have used for $$$A$$$.$$$\newline$$$ Constraints :- $$$A_{i}, B_{i} \le 10^{9}$$$ and, size of the arrays $$$\le 10^{5}$$$. Please can anyone help me in solving this??

Full text and comments »

  • Vote: I like it
  • +12
  • Vote: I do not like it

By helloIamCristiano, history, 20 months ago, In English

Given 2 arrays A and B of size m and n respectively. The array A is extended by concatenating n copies of A to itself and array B is extended by concatenating m copies of B to itself, thus the new size of each array is m*n. Find the sum abs(A[i]-B[i]) for i from 0 to m*n-1.

Constraints :-
A[i], B[i] <= 50 and Length of the arrays A, B < 1e5

Full text and comments »

  • Vote: I like it
  • -10
  • Vote: I do not like it