Problem 1 (Team) by Codeforces
My solution in C (view PDF)
My solution in C (download CPP file)