I'm very often have ACCESS_VIOLATION.
For example, in task 1079
http://acm.timus.ru/messages.asp?id=4539 And in this too. Why??
#include <iostream.h>
int begin [10000], end [10000];
void sort (int l,int r)
{
int i,j,x,y;
i=l; j=r; x=end[(l+r) / 2];
do
{
while (end[i]<x) i++;
while (x<end[j]) j--;
if (i<=j)
{
y=end[i]; end[i]=end[j]; end[j]=y;
y=begin[i]; begin[i]=begin[j]; begin[j]=y;
i++; j--;
}
} while (i<j);
if (l<j) sort(l,j);
if (i<r) sort(i,r);
}
void quicksort (int Lo,int Hi)
{
sort(Lo,Hi);
}
int main ()
{
long n;
cin >> n;
for (long i=1; i<=n; i++) cin >> begin [i] >> end [i];
int last=1,now=1,all=1;
quicksort (1,n);
while (now<n)
{
while (begin [++now] <= end [last])
if (n == now)
{
all--;
break;
}
last = now;
all++;
}
cout << all;
return 0;
}