One test case showing wrong answer

#include
#include
using namespace std;
void prime(int a[]){
for(long long int i=3;i<500000;i=i+2){
a[i]=1;
}
for(long long int i=3;i<500000;i=i+2){
if(a[i]==1){
for(long long int j=i*i;j<500000;j=j+i){
a[j]=0;
}
}
}
a[1]=0;
a[0]=0;
a[2]=1;
}
int main(){
int a[500000]={0};
prime(a);
vector primes;
for(long long int i=0;i<500000;i++){
if(a[i]==1){
primes.push_back(i);
}
}
int n;
cin>>n;
cout<<primes[n-1]<<endl;
return 0;
}
all cases are working fine but one test case is showing wrong answer

Hello @professor,

You need to find more prime numbers as the constraint is a large value.

Corrected code:

Hope, this would help.

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.