Friday, 23 August 2013

Editorial - C For Code 06 - Coding Club - ISM Dhanbad

Joey is Hungry

This Problem was taken from here: http://codeforces.com/contest/276/problem/A
It appeared as the easiest question of Codeforces Round #169 (Div. 2). I solved it after 7 minutes and 2 seconds without any penalty.
For all the test cases and my solution during the real contest, see this:

Let Vi be the fun for i-th restaurant, then
If( ti <= K)
                Vi = Fi
Else
                Vi = Fi – (Ti – K )
Find the maximum of all such Vi, that will be the answer.

Here is my solution:



Ross got a puzzle

This problem was taken from here: http://codeforces.com/contest/248/problem/B
It appeared as the second easiest question of Codeforces Round No. 152 (Div. 2). I solved it after 32 minutes and 44 seconds and no penalty.
For all the test cases and my solution during the real contest, see this:

The solution was based on the fact that the only possible combination of last 3 digits were: 170, 020, 200, 110, 050, 080. See the solution for more clarification:



India has a plan

This problem was taken from here: http://codeforces.com/contest/278/problem/C
It appeared as the third easiest question of Codeforces Round No. 170 (Div. 2). I solved it after 1 hour 31 minutes and 46 seconds without any penalty.
For all the test cases and my solution during the real contest, see this:

Build bipartite graph with n nodes for all the persons and m nodes for languages. If a person initially knows a language, than there will be an edge between corresponding nodes. Now the problem is simple: add the minimal number of edges in such a way, that all the n persons will be in the same connected component. Obviously, this number equals to the number of initially connected components, containing at least one person, minus one. But there is one exception (pretest #4): if initially everyone knows no languages, we'll have to add n edges, because we can't add the edges between persons (remember that the graph is bipartite).

Here is my solution to this problem:


No comments:

Post a Comment