Resource waste caused by two programs in one job

I submitted a job and applied for 96 CPUs, which will run two programs in sequence. Program 1 is estimated to take 3 hours and use 96 CPUs, while Program 2 runs after Program 1 and is estimated to take 4 hours. However, it only requires 4 CPUs, which would result in resource waste. I found that the job dependency method can be used, but it needs to submit two jobs, and must first obtain the jobid of the first job. Is there a simpler way to handle this situation in only one job? Looking forward to any useful assistance.