Prompt Gamma Neutron Analysis Activation is a widely used technique for analyzing materials. This technique defines graphs (reference spectrum collection, or libraries) of spectral intensity as a function of energy (channels) for the elements inserted in a sample. The Monte Carlo Library Least Squares (MCLLS) is the dominant approach in the PGNAA technique. The main difficulties faced in the MCLLS domain are (1) numerical instabilities in the least-squares stage (Library Least Squares (LLS)); (2) overdetermination of the system of equations; (3) linear dependence in the libraries; (4) gamma radiation scattering; (5) high computational costs. The present work proposes optimizing the LLS module to face the abovementioned problems using the Greedy Randomized Adaptive Search Procedure (GRASP) and Continuous Greedy Randomized Adaptive Search Procedure (CGRASP) algorithms. The search for the spectral count peaks of the libraries leads to a partitioning of the data before applying the GRASP and CGRASP algorithms. The methodological procedures also address estimating the spectral counts of an unknown library possibly integrates the sample. The results show (1) efficient partitioning of the input data (2) evidence of suitable precision of the weight fractions of the libraries that make up the sample (average precision of the order of 3.16% against 8.8% of other methods); (3) success in the approximation and estimation of the unknown library (average precision of 4.25%) present in the sample. Our method proved to be promising in improving the determination of percentage count fractions by the least-squares module and showing the advantages of data partitioning.