A function F(A,k) has two arguments, an array of integers A and an integer k and is defined as: You generate all subsequences of array A that are of size k (there are (size(A)k) such sequences), then for every sequence you pick the maximum element and sum them (see sample case for more detail). More formally:
Let us define a function G(A) as:
You are given the array A and have to find the value of the G(A) mod 109+7.
Note: (nk)= Cnk
Subsequences for k = 1 i.e. subsequences of size 1: {1},{2},{3}
Subsequences for k = 2 i.e. subsequences of size 2: {1,2},{2,3},{1,3}
Subsequences for k = 3 i.e. subsequences of size 3: {1,2,3}
F(A,1)=max({1})+max({2})+max({3})=1+2+3=6
F(A,2)=max({1,2})+max({2,3})+max({1,3})=2+3+3=8
F(A,3)=max({1,2,3})=3
G(A)=F(A,1)+F(A,2)+F(A,3)=6+8+3=17