@avanee : You should give us the link to the problem and your submission . You have pasted your code which is OK , but we don’t know what kind of input it will be subjected to while running because we don’t have link to the problem . Therefore we don’t know when it might throw an exception / crash .
The simplest reason, that appears at a single look on your code is because, you have some loops running from 1 to m, which has some array indexing in them. Make sure that no “out of index” accesses occur in the array. What is the max value m can have? (Keep in mind, array indexing starts from 0. So, if max possible value for m is >= 100, then a[i] when i=100 is prone to crash.)
@betlista has already pointed out . Note the constraint below given in the problem .
0 <= M <= min(N(N-1)/2, 300,000)
You have written the code :
for(i=1;i<=m;i++){
if(a[i].second==n&&a[i].first<=mini){
So your array a , should have indices upto ‘m’ defined , right ?? So your array should be 3,00,000 in size .