Codeforces Round #222 Problem C Captains Mode