Rating changes for the last round are temporarily rolled back. They will be returned soon. ×

cpforfunCmnt's blog

By cpforfunCmnt, 5 weeks ago, In English

PLEASE DON'T DOWNVOTE WITHOUT READING BLOG,YOU CAN JUST IGNORE IT IF YOU DONT WANT TO HELP

Hey community, somedays ago there had a gym contset named "Belarusian round #2: Simran, Muskan, Divyansh, Pranjal and their problems" which had some really cool problems.

I had some idea of PROBLEM C of that contest and but it failed,and cause it has no editorial and we cant see other code I am not getting how to do this.

WHETHER YOU HAVE DONE THAT QUESTION OR NOT ,I SINCERLY HOPE THAT YOU GO THROUGH PROBLEM ONCE.

First of all this is question link: PROBLEM C

If you hadn't registered in that contest here is link to register: Belarusian round #2

AND AT LAST HERE IS FAILED APPROACH:

WRONG LOGIC

Edit:See WE cant't see accepted code

 
 
 
 
  • Vote: I like it
  • -47
  • Vote: I do not like it

»
5 weeks ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Please don't write a blog for these queries, you can always see the solutions of people who solved it.

Anyway, In this question you have to find the maximum of (a1*a2*⋅⋯⋅ai) + (ai+1 * ai+2 *⋅⋯⋅an).. for this, you can make a prefix product array and suffix product array modulo m , say pref[] and suff[]

now itterate over all possible i and do this, ans = max(ans, (pref[i-1]+suff[i])%MOD );

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    First of all PR_0202 I have given proof that we cant see accepted code.

    Secondly,I want to ask isnt that we have to minimse the negative value, so why not we chose

    max(product till first time negative come +rest(pos value),in reverse producct till first time negative come+rest(positive value))

    Can you tell me why this isn't optimal?

    Also I think your code will not pass all test cases.

    • »
      »
      »
      5 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Bro try for this test case: 1 2 3 4 5 6 7 -1000000 -1000000

      I want to ask isnt that we have to minimse the negative value for this doubt, you can think over a test case where every element in the array is negative.

      Also, you added the proof after my comment xD

      • »
        »
        »
        »
        5 weeks ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        For this testcase : 1 2 3 4 5 6 7 -1000000 -1000000 if count of negative is even then we just return product of all array(I have even written this above)

        you can think over a test case where every element in the array is negative. OKK let suppose I have arr={-1,-2,-3,-4,-5}

        so its obvious that in our answer one term is going to be pos and other negative And our ans will be maximum if we have high pos value and low neg value,,if we choose some middle index let 3 then its obvious that our pos value will reduce and negative value increases,so its always going to be optimal at both extreme.Isn't it.

        Have u any corner case for this point.

        Btw thanks for helping.

        • »
          »
          »
          »
          »
          5 weeks ago, # ^ |
            Vote: I like it +1 Vote: I do not like it

          Your logic is correct but how will you find maximum of those two values.

          you need to maximise ans, not ans%mod

    • »
      »
      »
      5 weeks ago, # ^ |
        Vote: I like it +1 Vote: I do not like it

      Also, you need to maximise ans, not ans%mod.. You need to handle this in your code.

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it +6 Vote: I do not like it

    Gym contest codes are not visible to any coder who is rated lower than a candidate master.

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    Bruh moment!

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

EnterYourName , Maksim1744 , Test2311 , _Chaitanya1999 can you all please share your code and idea behind that??

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    cpforfunCmnt You can see anyone's submission now.

    In your approach let say you have even number of negative numbers, you claim that the answer is the product of array

    Consider [-1,-1,2,3,4] Your claim is that the answer is 24 as per your logic ,

    but we can split it as [-1,-1] and [2,3,4] to get the sum of products as 1 + 24 = 25.

    • »
      »
      »
      5 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      NO,I am not wrong at that cause I have handled that extreme case that if first or last is one then product of rest+1...still I cant find whats wrong in my approach but I have got ac code credit:EnterYourName thanks man:)

    • »
      »
      »
      5 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Thanks Radhe_Loves_To_Eat ,I can see all submissions now also I got to know that u was writer of that contest ...

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it +1 Vote: I do not like it
»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Was it Rated or not ?