Hello coders,

I’d like to ask question about TRAINING problem from last (April 2012) short contest.

I submitted this solution, here is pastebin version (just because there is code highlighting).

Idea is simple (inspired by tutorial) - sort kids by height (secondary by weight, both decreasing), get the first one not afraid of anyone (in code referred as captain). All other kids have less height, so they are potentially afraid of the one. But the kids with greater weight are not afraid, so we can add them to the team.

I believe that my code runs in O(N*log(N)), but I’m getting TLE. Did I missed something?

1 Like