Блог пользователя Alpha_Ashwin007

Автор Alpha_Ashwin007, история, 9 месяцев назад, По-английски

Invitation to CodeChef Starters 110 (Rated till 5-stars) — 29th November

We invite you to participate in CodeChef’s Starters 110, aka Shaastra Programming Contest , conducted by Shaastra IIT Madras and sponsored by KLA+, this Wednesday, 29th November, rated till 5-stars (ie. for users with rating < 2200).

Time: 8:00 PM — 10:00 PM IST

Register here to be eligible for the offline finals where there are prizes worth 60000 INR.

Joining us on the problem setting panel are:

Written editorials will be available for all on discuss.codechef.com. Pro users can find the editorials directly on the problem pages after the contest. The video editorials of the problems will be available only to Pro users.

Also, if you have some original and engaging problem ideas, and you’re interested in them being used in CodeChef's contests, you can share them here.

Hope to see you participating.

Good Luck!

  • Проголосовать: нравится
  • +4
  • Проголосовать: не нравится

»
9 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

what is error in this https://www.codechef.com/viewsolution/1032623090 for Tom and jerry problem

»
9 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

In the problem "World Cup", any pointers as to why the following idea doesn't work?

  • Consider I take some set $$$S$$$ ($$$|S| \lt n$$$) of matches such that the shortest unused match has length $$$y$$$. Then it is clearly optimal to distribute the matches in $$$S$$$ with a gap of $$$y - \epsilon$$$ between them. Practically this means I can cover a period of $$$(|S| + 1) \cdot y - 1 + \sum_{x \in S}{h_x}$$$ days without being able to fit any match.

Since:

  1. $$$y$$$ clearly depends on selecting all matches with length $$$\lt y$$$.

  2. For a fixed $$$y$$$ and |S|, we want to maximize $$$\sum_{x \in S}{h_x}$$$ by picking the largest remaining possible values.

  • From (1) and (2), any optimal set of matches consists of a combination of the $$$i$$$ shortest matches and the $$$j$$$ longest matches.

  • So we can just iterate over the values of $$$i$$$ and $$$j$$$ and find the minimum value of $$$i + j$$$ which satisfies $$$(i + j + 1) \cdot a_{i + 1} - 1 + \sum_{x = 1}^{i}{h_i} + \sum_{x = 0}^{j - 1}{h_{n - j}} \geq H$$$.

I feel like I'm misunderstanding something key about the problem or approach.

  • »
    »
    9 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    For a short while, this was the intended solution. But it doesn't work since "the j largest matches" have to satisfy another constraint, which is that the sum of all the chosen h_i should be <= H. Surprisingly, this throws a huge spanner in the works, and it is actually not true that the optimal set is a combination of some shortest and some longest matches.

    Also, why the "- 1" in the LHS?

    • »
      »
      »
      9 месяцев назад, # ^ |
      Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

      Ah, got it. If I have h = [1, 1, 3, 9, 10] and H = 15, the only optimal choice of matches is $$$[3, 10]$$$.

      Regarding the "-1", when considering the $$$|S| + 1$$$ gaps around the $$$S$$$ elements, keep in mind we can only make the gap as large as $$$y - \epsilon$$$, so the total integer length we can cover is $$$(|S| + 1 \cdot y) - 1$$$, right?

»
9 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Why in the world a $$$dp[N][2][2]$$$ solution gives TLE in tetris?

  • »
    »
    9 месяцев назад, # ^ |
    Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

    You must be re-evaluating the $$$dp$$$ array inside every test case. But the answers from previous test cases can also be used.
    So just don't make the $$$dp$$$ array filled with $$$-1$$$ for every test case.
    My Submission

    • »
      »
      »
      9 месяцев назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      I tried that , but instead of last as 1 to 4 , i took it as boolean if last = 4 or not,there not re-initializing my dp gave WA.

  • »
    »
    9 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    There is no constraint on $$$\sum {N}$$$ over all test cases.

    At least for my $$$dp[N][2]$$$ state (lines filled, cur player), the answer is just the sum of the states $$${[L - 4][0], [L - 3][0], [L - 2][0], [L - 1][0]}$$$. So just precalculating up to $$$10^5$$$ (the max possible value of $$$k$$$) solves the issue.

»
9 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Cant understand why this is wrong . please help ! https://www.codechef.com/viewsolution/1032506038