Prata code wrong answer

here is my code for Prata spoj, pls check what is wrong
.
.
.
#include <bits/stdc++.h>
#define ll long long
#define endl “\n”
using namespace std;

long check(ll m,ll a[],ll n)
{
ll c=0;
for(ll i=0;i<n;i++)
{ ll j=0,t=1;
while(a[i]j<=m)
{
j+=t;
t++;
//j
=a[i];
c++;
}
c–;
}
return c;

}

int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;cin>>t;
while(t–)
{ ll p;cin>>p;
ll n;cin>>n;
ll a[n];
ll i;
for(i=0;i<n;i++) cin>>a[i];
sort(a,a+n);
ll s=0,e=0,ans;
for(i=1;i<=p;i++)
{
e+=i;
}
e*=a[0];
// cout<<e<<endl;
while(s<=e)
{ //cout<<1;
ll m=(s+e)/2;
ll x=check(m,a,n);
if(x<p) s=m+1;
else if(x>p) {
ans=m; e=m-1;
}
else if(x==p) { ans=m; break ;}
}
cout<<ans<<endl;
}
return 0;
}

share code in cb ide

i dont have the code anymore.

its impossible for me to debug the code this way

there are lot of problem when i copy this code the compiler

please make the code again and share in ide

i didnt received any problem while copying this code .

@mehulbhandari358
if u open it in the editor u can see the no of errors u get

image the operators are missing

okay !

i have send you the new code above have you checked it ?

sorry i skipped it please wait.


refer to this !!

have you checked mine

@mehulbhandari358
bro i think tere check function meh dikat h
read the logic here


i have updated ur check function and the code runs fine