Vvvv ffhh ssfhh sghjj

Vvvcbdf fgfdgg schgfd jhrfgh ssfhh dgbff
rthgb
wrwgb
wr
wrb
wbg
wgb

Did you tried clustering of people such that replace same group people with sum of skills and salary? So now same problem without group.

It is classical Knapsack Problem. Using dfs or DSU find the groups. Consider these groups as single entity. Apply knapsack algorithm.