Posts

Showing posts with the label QUESTION

TCS CodeVita 2016 Round1 Question: Min Product Array

Image
The task is to find the minimum sum of Products of two arrays of the same size, given that k modifications are allowed on the first array. In each modification, one array element of the first array can either be increased or decreased by 2. Note - the product sum is Summation (A[i]*B[i]) for all i from 1 to n where n is the size of both arrays Input Format:   First line of the input contains n and k delimited by whitespace Second line contains the Array A (modifiable array) with its values delimited by spaces Third line contains the Array B (non-modifiable array) with its values delimited by spaces Output Format: Output the minimum sum of products of the two arrays Constraints: 1 ≤ N ≤ 10^5 0 ≤ |A[i]|, |B[i]| ≤ 10^5 0 ≤ K ≤ 10^9 Sample Input and Output SNo. Input Output 1 3 5 1 2 -3 -2 3 -5 -31 2 5 3 2 3 4 5 4 3 4 2 3 2 25 Explanation for sample 1: Here total numbers are 3 and total modifications allowed are 5. So we modified A[2], which is ...