Why am I getting SIGSEGV

My code for this is giving sigsegv error. Many solutions with similar approach got AC.

I also tried to solve it using structure, but couldn’t sort it. sort() of STL didn’t work for it. I don’t know why.

My code

Tried using structure . If I remove sort(), then of course the answer is wrong, but I am getting wrong answer, not RE.

hello sir,i am fairly new in competitive coding and structures always scared me.I want to ask something related to your solution.Can you please tell me what is use of array of structure??What i am assuming that it is used to extend storage of array from one variable of one type to many variable of many different type.Correct me if i am wrong and it will be best if you(or anyone else)can elaborate about it and provide some question which can be solved using this.Thanks in advance

Stack overflow is the most probable reason for SIGSEGV. Try to make abc vector global.
Also note than N can be zero.

You are correct. Structure of array allows you to store multiple things about an object consecutively in memory and hence allows you to easily access each element. In my program, I needed to store three things about each input (starting time, end time and preferred location) and I had multiple inputs. So, instead of using three arrays, I used one structure (each with three elements) of arrays.

I have used structure many times for class assignments, but it is the first time I am using it in competitive programming. In class, it is easy as minor errors are overlooked. But not in online judge.