When you write/launch a PBS script, you are not supposed to know what resources are available, you are supposed to describe what resources do you need. And while the efficient use of HPC resources is important, you should not take the work of the job scheduler.
However, I guess you are interested in the ability to request different
ppn for different nodes. This can be done using the following type of request (with
#PBS -l nodes=1:ppn=3+1:ppn=8+24
#PBS -l naccesspolicy=SINGLEJOB -n
That is supposed to request 3 nodes with 8 ppn and 1 node with 24 ppn. The question is if your scheduler is configured to process such requests is open. More about that here or in the official PBS manual.
Now, since the resource availability is changing and dynamic with time, your PBS scripts have to be generated using some kind of a shell script that will check the available resources and generate the corresponding PBS file.
As a summary: I, personally, do not advise going this route and certainly check with HPC cluster administrators if such dynamic resource requests are even compliant with "good citizen" policy. And even if they are, I still think that you are taking a chunk of the scheduler work into your hands unnecessarily.