Problem with UVa Online Judge
<p>I tried to solve 195 problem. Here it is.</p>

<p><a href="http://uva.onlinejudge.org/index.php?option=com_onlinejudge&amp;Itemid=8&amp;page=show_problem&amp;category=3&amp;problem=131&amp;mosmsg=Submission+received+with+ID+9118309" rel="nofollow">http://uva.onlinejudge.org/index.php?option=com_onlinejudge&amp;Itemid=8&amp;page=show_problem&amp;category=3&amp;problem=131&amp;mosmsg=Submission+received+with+ID+9118309</a></p>

<p>Here is my solution.</p>

<p><a href="http://pastebin.com/xt9AhiTL" rel="nofollow">http://pastebin.com/xt9AhiTL</a></p>

<p>I tries examples from the site and the result was the same. But I've got 'Wrong Answer'.
Please, help to find mistakes and give some ideas how to fix them.
PS: I know that my algorith is awful, but it works :)</p>

<hr>

<p>Thanks for advices. I finally found the solution. I have not read the solution properly...</p>
