C# – CodeForces 360 – Two Simple Tasks

This Wednesday I have not participated in the CodeForces competition – I was either too tired on Wednesday or I had something better to do. 🙂 Anyhow, I have just taken a quick look at the first two problems of the competition and as usually happens when person solves the problems outside a competition I have managed to solve them unexpectedly quick. The second problem actually was solved in 4 minutes (coding, reading and submitting) and I was quite surprised for it. The first one was also solved rather fast 🙂 Let’s hope that on the next competition I would be having the same success as today 🙂cs

Here is the first problem

The idea is to find the maximum sequence of days, in which we do not get all enemies at school. At first it seemed rather easy, but then I realized that I need a quick way to make the numbers with which I am comparing. Thus, I have built the function CheckNumber(int enemies_count), with the idea to compare strings and not integers, because it would be faster this way and I would not go outside range. It was a trick that in the problem the maximum of enemies was not given, thus someone can put like 100 enemies, which would make even big integer overflow. Once, this was made, I simply wrote every result per day in a list and at the end I have displayed the maximum of this list. Literally nothing could have been wrong there.

Here is the second problem

In the second problem I really thought that something was wrong – it was unbelievably easy for a second one. You simply have to take the input, reverse it and write it. Probably the problem was tough, that you should realize this by reading the problem. But once you think about 30 seconds, you realize what they want from you.

Pretty much that is all. Here is the code of the first problem:

Here is the code of the second one:

Here comes the code in GitHub.