Sort by

recency

|

4 Discussions

|

  • + 0 comments

    Celebrity IQs often grab attention, but intelligence is multifaceted. Success in entertainment doesn’t always correlate with a high IQ—it’s a mix of creativity, social skills, and determination too.

  • + 0 comments

    function Max(AA){ let maxc = AA[0]; for(let k=0;k

    return ret;
    

    }

    function solve(A) { // Return the sum of S(S(A var m = 1000000007; var res = 0; var Max_A_i_j = Max(A); var total = Max(A); var sum = Sum(A); var B = A; var A_i_j = []; var slice = A; var j = A.length ; var e_idx = 0; A_i_j = A.slice(0,j-1); B = Append(B,A_i_j); B = Append(B,[Max(B)]); B = Append(B,A_i_j); B = Append(B,[Max(B)]); console.log("-----------------------------------") console.log("i j k A[i,j] Max[A[i,j]") console.log("-----------------------------------") for(let k=0;k //total+= Max(Max_A_i_j); }else{ Max_A_i_j = Max(A_i_j); B = Append(B,A_i_j); console.log(i," ",j," ",k," ",A_i_j," ",Max_A_i_j); total += Max_A_i_j;
    sum = Sum(B);

                }
    
    
            }
    
        }
    }
    console.log(B,total,sum);
    console.log("-----------------------------------")
    return sum;
    

    }

  • + 1 comment

    for complete solution in python java c++ and c programming search for programs.programmingoneonone.com on google

  • + 1 comment

    I have written below code for this problem. It fails with timeout for testcases other than first one. For firtst one it works fine

    !/bin/python3

    import sys

    def solve(A): # Return the sum of S(S(A)) modulo 10^9+7. total=sum(A) for _ in range(len(A)-1): b=A[:] for k in range(1,len(A)): for i in range(len(A)-k): j=i+k+1 x=max(A[i:j]) b.append(x) total+=x A=b[:] return total if name == "main": n = int(input().strip()) A = list(map(int, input().strip().split(' '))) result = solve(A) print(result)

No more comments