Computer Science, asked by manchalavasundhara, 1 month ago

Robin goes to a food festival along with N-1 friends. Robin is labeled as 1 and his friends are labeled from 2 to N. Each of them has a set of colored coupons The food festival has M food stalls numbered from 1 to M. Every food stall accepts particular color coupons only. There are 10 different color coupons represented by numbers ranging from 1 to 10. You are given certain number of queries Q. Find the sum of the outputs of all the queries Input Specification: input1: N, total size of the group of friends including Robin input2: M, number of stalls input3: A two dimensional array of size M* 10, where cell(i, j) = 1 denotes that stall i accepts coupon input4: A two dimensional array of size N* 10, where cell(i, j) = 1 denotes that person i has couponſ inputs: Q number of queries inputs: A two dimensional array of size Q* 2. containing sets for which the query has to be answered.​

Answers

Answered by perumandlasoujanya79
7

Answer:

The product is not calculated normally though. To make the game interesting, the first box of subsequence A is to be multiplied by the last box of subsequence B. The second box of subsequence A is to be multiplied by the second last box of subsequence B and so on. All the products thus obtained are then added together.

If the participant is able to find the correct such maximum summation, he/she will win the game and will be awarded the food voucher of the same value.

Note: The subsequences A and B should be disjoint.

Example:

Number of boxes, N = 8

The order of the boxes is provided below:

Subsequence A = 9 2 3

Subsequence B = 6 7 8

The product of the subsequences will be calculated as below:

P1 = 9 * 8 = 72

P2 = 2 * 7 = 14

P3 = 3 * 6 = 18

Summation, S = P1 + P2 + P3 = 72 + 14 + 18 = 104

This is the maximum summation possible as per the requirement for the given N boxes.

Tamanna is also in the fest and wants to play this game. She needs help in winning the game and is asking for your help. Can you help her in winning the food vouchers?

Input Format The first line of input consists of the number of boxes, N.

The second line of input consists of N space-separated integers.

Constraints 1< N <=3000

-106 <= I <=106

Explanation:

Please make me the branilest

Stay Home

Stay safe

Similar questions