Codeforces 1133C. Balanced Team Codeforces Round #544 (Div. 3)


Problem link

Let's sort all values in non-decreasing order. Then we can use two pointers to calculate for each student i the maximum number of students j such that aj−ai≤5 (j>i). This is pretty standard approach. We also can use binary search to do it (or we can store for each programming skill the number of students with this skill and just iterate from some skill x to x+5 and sum up all numbers of students).

A solution in c++








Post a Comment

0 Comments