Computer Science, asked by abhishekgoel1999, 4 months ago

There are N number of boxes arranged in a single queue. Each box has an integer I written on it. From
the given queue, the participant has to select two contiguous subsequences A and B of the same size.
The selected subsequences should be such that the summation of the product of the boxes should be
maximum. 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.​

Answers

Answered by sujal23805
10

from your question .

subsequences A and B of the same size.

The selected subsequences should be such that the summation of the product of the boxes should be

maximum. 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

Answered by akankshabharatiyasl
0

Answer:

/*Enter your code here. Peruse input from STDIN.

Print your result to STDOUT"/

#incorporate <iostream>

#incorporate <cassert>

02 446

utilizing namespace sexually transmitted disease;

template<class T> inline void umax(T &a,T b)

[if(a<b) a = b;}

template<class T> inline void umin(T &a,T b)

[if(a>b) a = b;}

template<class T> inline T abs(T a){return a>0 ?

template<class T> inline T gcd(T a,T b)[return - gcd(a, b);}

template<class T> inline T Icm(T aT b)[return gcd(a,b)*b:)

typedef long lengthy II:

typedef pair<int, int> li:

a/

const int inf=1e9 +143;

const II longinf = 1e18 + 143;

Inline Int read()

int x;scanf("%d",&x);

bring x back;

const int N-20001:

int n;

int a[N]:

void read_inp()

f

n = read());

assert(1-n && n <-20000);

for(int i=1;i<n;i++)

a[i]= read():

assert(abs(all) <= int(16));

}

int principal()

#ifdef KAZAR

freopen("f.input","r",stdin);

freopen("f.output", "w".stdout); freopen("error","w",stderr);

#endif

read_inp():

Il ans = - longinf; for(int i=1; I < n; i++)

Int 1-1-1, - 1; Il best Oll, mutt = Oll; while() >= 1 && r <=n)

Il val = (I)a[] a[r]:

dog - val; umin(best, mongrel); umax(ans, mutt best); -

446

Int 1-1-1,- 11; Il best = Oll, dog = Oll; while(l=1&& r <=n)

Similar questions