SRM605.

Before SRM started thinking about rainbow.
That's why coded first problem in Java.
Second one turned out to be easy, but I had been working on it about 50-55 minutes.
Found out that bruteforce of about 40M iterations (simple 1-byte comparison) in C++ takes 0.1 sec. on TopCoder servers. Not bad.

Lessons learned:
- Always think about the algorithm in advance. I started implementation having only a vague idea on how to do it.
Found that when I start writing wrong algorithm, I end up with very long thinking about the solution.
- Practice.