#include #define MAX(a,b) ((a)>(b)?(a):(b)) int calc(int *a,int n,int *b,int m){ int res=1; int s=n-1; int t=m-1; while(1){ while(t>=0 && a[s]<=b[t]) t--; if(t<0) return res; res++; while(s>=0 && b[t]<=a[s]) s--; if(s<0) return res; res++; } return 0; } void sort(int *a,int n){ int i,j; for(i=1;i=0 && p