I'll give you a traveling salesman variant: find the shortest tour visiting cities. Use next_permutation to try all possible routes and track the minimum distance found. Sort city indices first, then loop through all permutations calculating distance for each route.
Keep track of the minimum total distance across all orderings you try. This brute force works for cities. Larger inputs need dynamic programming or approximation algorithms since permutations grow factorially in count.