Showing wrong ans

#include
using namespace std;

bool poss(int a[],int p,int m,int n){
int paratha=0;
for(int i=0;i<n;i++){
int time=a[i];
int j=2;
while(time<=m){
paratha++;
a[i]*=j;
j++;
time+=a[i];
if(paratha==p){
return true;
}

	}
}
return false;

}

int main() {
int p,l;
cin>>p;
cin>>l;
int a[l];
for(int i=0;i<l;i++){
cin>>a[i];
}
int i=a[0];
int s=0;
int e=a[0];
for(int j=2;j<=p;j++){
i=j*a[0];
e+=i;
}
int ans=e;
while(s<=e){
int mid=(s+e)/2;
if(poss(a,p,mid,l)){
ans=mid;
e=mid-1;
}
else{
s=mid+1;
}
}
cout<<ans<<endl;

return 0;

}

I have make changes in your code
also commented the logic

Modified code

i made change in int e value of mine acording to your value but still wrong ans .and my and your code seems same then what is error in my code

there the some other differences as well

i have also make changes in possible function poss()

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.