Why my first two test case is not passing

#include
using namespace std;
#define ll long long int

int main() {
ll mx=5000001;
ll ar[mx]={0};
for(int i=1;i<=mx;i++)
{
ar[i]=1;
}
for(int i=2;ii<=mx;i++)
{
if(ar[i]==1){
for(int j=2
i;j<=mx;j+=i)
{

				ar[j]=0;
			
		}
        }
	}
ll n,c=0,val;
cin>>n;

for(int i=2;i<mx;i++)
{
	if(ar[i]==1)
    {
       c++;
	   if(c==n)
	   {
		   val=i;
		   break;
	   }
    
    }
}
cout<<val;
return 0;

}

@ayushwahi3005
hello ayush,
as per given constraint n can be upto 5000000 so ur sieve size should be larger than 5000000th prime number
image

find 5000000th prime number and define ur sieve size accordingly

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.

https://ide.codingblocks.com/s/223998 My 1st and 2nd test case is not passing why?

delcare ur sieve size greater than or equal to 86028122.
it will pass all test cases.

its showing TLE when I take 86028122

check this ->

compilation error when I run your given code

please try again
it is working fine
image

thanks it passes all test case