We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Loading...
  • Practice
  • Compete
  • Jobs
  • Leaderboard
  • Hiring developers?
  1. Practice
  2. Algorithms
  3. Dynamic Programming
  4. Separate the chocolate
  5. Discussions

Separate the chocolate

  • Problem
  • Submissions
  • Leaderboard
  • Discussions
  • Editorial

Sort 17 Discussions, By:

votes
  • recency
  • votes

Please Login in order to post a comment

  • sameerpm 5 years ago+ 1 comment

    In example, all 4 are U (not even one is TT or D)...Then how in o/p you are showing T D and U

    8|
    Permalink
    • sharukrules 2 years ago+ 0 comments

      I think they are showing who got which part of the piece. Its all U, But D denotes Derpina got the U chocolate.

      0|
      ParentPermalink
  • josef_klotzner 6 months ago+ 1 comment

    The sample test case is wrong for my understanding:

    1 1 1

    T

    Answer as of test case: 1

    Problem description states, to split chocolate in exactly TWO pieces. To give Tom just 1 piece (all) and Derpina nothing is no split at all. (nothing is not a piece)

    Correct answer for my understanding: 0

    Because it can't be split into "exactly TWO pieces"

    What do You think?

    1|
    Permalink
    • gondo 5 months ago+ 0 comments

      Exactly my first thought

      0|
      ParentPermalink
  • kumanoit 5 years ago+ 1 comment

    "The absolute difference between the number of chocolates in pieces should be at most K". Which difference is being referred here? is it Absolute(numberOfChocolates(T) - numberOfChocolates(D)) ?

    1|
    Permalink
    • xxxxxyyyc 4 years ago+ 0 comments
      [deleted]
      0|
      ParentPermalink
  • gugigor 6 months ago+ 0 comments

    the statement probably should've said that you can't leave any piece of chocolate unattended, since the wording was a bit vague on whether you had to use all of it or not

    0|
    Permalink
  • mikhail_lokhanov 1 year ago+ 0 comments

    Solved locall, but cannot upload code: Sorry, we can't accept your submission. Your submission size should not exceed 50 KB. Reduced it to 45K by removing all comments (used to be 110K)... still cannot uoload... Grrr

    0|
    Permalink
  • mrussotto 3 years ago+ 0 comments

    Did it via DP, but there wasn't enough memory to do a full DP; could only memoize SOME steps. You know you're hacking when your code starts with

    typedef unsigned int ulong;

    0|
    Permalink
  • aka_julie 3 years ago+ 1 comment

    It should be Derp and Derpina smh

    0|
    Permalink
    • lokeshlkr 2 years ago+ 1 comment

      Then all the chocolates would have been marked D and our program would get confused which D was for which Derp and which was for Derpina. XD

      -2|
      ParentPermalink
      • 16chen_george 2 years ago+ 0 comments

        dude...stop trying m8. Not even funny bruh

        -1|
        ParentPermalink
  • Vaishnavi_Mande 3 years ago+ 1 comment

    Is it that you cannot have a 2X2 piece? Or any piece you cut shouldn't contain a piece that has a square? For example - test case - 3 3 4 UDD UUT UTT

    So, is dividing the piece like DDD TTT TTT

    valid?

    0|
    Permalink
    • gondo 5 months ago+ 0 comments

      the statemant is: in any piece , therefore no, your example is not valid

      0|
      ParentPermalink
  • adrient 3 years ago+ 1 comment

    My C# algorithm times out for the three last cases. Is there a way to avoid checking the global connectivity of both T (through T and U) and D (through D and U) each time I assign a U to either T or D?

    0|
    Permalink
    • sufertashu 3 years ago+ 0 comments

      Same problem.

      0|
      ParentPermalink
  • wariotx 4 years ago+ 2 comments

    If m=2, n=5:

    TTDDD
    TTDDD

    is it valid or not?

    0|
    Permalink
    • giaym 3 years ago+ 0 comments

      you cant have 4 in a block so I guess no

      0|
      ParentPermalink
    • nkongchatri 3 years ago+ 0 comments

      Must have i/p k to determine how the diffence between two pieces is allow and initial labed chocolate like

      TTUUD
      UUUDU
      

      if you i/p has k=2 then some of the posible divition will be

      TTTDD
      TTDDD 
      
      TTTTD
      DDDDD
      
      TTTTD
      TTDDD
      
      TTDDD
      TTDDD  // yours
      
      1|
      ParentPermalink
Load more conversations

Need Help?


View editorial
View top submissions
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature