If one can factor p, using logarithms can transform the problem to look a lot like a set partitioning problem. The only required difference is that objective function is rather non-linear. Up to n2 elements of x may be greater than 1. This problem is at least as hard as factorization. The maximum of the empty set is minus infinity.
G is at least the second smallest prime factor, including duplications, of p and is at least two.
I suspect a greedy approach will work fairly well especially if followed by a 2-opt type improvement strategy. For a 2-opt type improvement solve a similar problem with only 2 variables. Even with brute force this can be done in polynomial time. I feel better, just for spite.