aman_naughty's blog

By aman_naughty, history, 6 years ago, In English

Problem Link : link

code link : code

In the bfs part I am extracting nodes at a given level and then in help function I am greedily sorting the CT and TT by CT time in acsending order as we want the developer to finish the module code asap so that the tester can attend to it. Also I believe that it doesn't matter if we process level 1 first and then subsequent levels as I am adding the time of each level to my answer. Why is this code giving WA. Any help is appreciated.

P.S- No one was able to solve this problem in the contest and thus it seems an interesting problem.

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

| Write comment?
»
6 years ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

Link for your code is private. Can you share it through ideone or pastebin?

»
6 years ago, # |
  Vote: I like it +13 Vote: I do not like it

I don't fully understand your explanation. By level you mean some depth (distance from the root)? We shouldn't group by that. The problem looks like bottom-up dp on tree.

If you don't know why your solution is wrong, write a brute force and compare them on random tests. More info: Asking for help FAQ.

  • »
    »
    6 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Yes by level I mean depth.

    • »
      »
      »
      6 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Can you please tell if the code to solve the subproblem is correct or not.

      Sub problem: given developer time array and tester time array find minimum time to completely develop and test all modules and tester can only test a module provided developer has coded it.

      My approach : Sort both arrays according to developer time in increasing order because we want to develop modules asap so that the tester can test it asap. Can you provide a counter case where my approach fails . Here is the code I am taling about.

      code

      d array is for developer and t array is for tester and a array is just storing the pairs of developer tester time for facilitating sorting.

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

        I told you to test it against a brute force...

        It's incorrect. One item with develop=10, test=1, the other develop=11,test=10.

        • »
          »
          »
          »
          »
          6 years ago, # ^ |
            Vote: I like it -18 Vote: I do not like it

          hello.......

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

            I told you two times what to do. I'm not going to help you more before you do that.