Tried the code, Didn't worked for all the test cases

Didn’t clear the test case:
Number of pratas to be ordered: 10
Number of cooks: 4
Rank array: 1 2 3 4

Expected output: 12
My ans: 6

Sharing my code:

Please mention the mistake

Please can anyone clear the doubt on this

there are some mistake in your code

  1. start should be
    1 because min time require to make any no of prata should be 1

  2. max time require to make P prata can be by laziest cook with rank 8
    time required will be 8r+16r+24r… ptimes
    calcultate sum formula will be
    int e=8*( P *(P+1))/2;

look at reference code if have any doubt ask me