Bin\run.sh...segmentation fault

#include<iostream
#include<set
using namespace std;

int main()

{

int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
{
  cin>>a[i];	
}
int k;
cin>>k;
multiset<int> b;
for(int i=0;i<k-1;i++)
{
	b.insert(a[i]);
}
for(int i=k-1;i<n;i++)
{
	b.insert(a[i]);
	cout<<*b.rbegin()<<" ";
	multiset<int>::iterator it=b.find(a[i-k+1]);
	b.erase(it);
}

return 0;

}
// works perfectly on my machine

@sxmeer_ahmed multiset is not correct data structure for this!
but still I don’t find any mistake in your code, I also manually checked it on test cases and they were passed too!
You may download the test cases and test it locally for which your code fails!

Yes your code is fine, there’s some problem at backend!

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.