Description:
Http://cs.scu.edu.cn/soj/problem.action? Id = 3316
# Include <iostream>
# Include <algorithm>
Using namespace STD;
Struct Node
{
Int start, end;
Bool visit;
} Fans [100 + 10], import [100 + 10];
Bool CMP (node A, Node B)
{
If (A. End! = B. End)
Return A. End <B. end;
Else
Return A. Start <B. Start;
}
Int main ()
{
Int n, m, I, J;
While (scanf ("% d", & N, & M) = 2)
{
For (I = 0; I <m; ++ I)
{
Scanf ("% d", & import [I]. Start, & import [I]. End );
}
For (I = 0; I <n; ++ I)
{
Scanf ("% d", & fans [I]. Start, & fans [I]. End );
Fans [I]. Visit = false;
For (j = 0; j <m; ++ J)
{
If (! (Fans [I]. End <= import [J]. Start | fans [I]. Start> = import [J]. End ))
{
Fans [I]. Visit = true;
Break;
}
}
}
Sort (fans, fans + N, CMP );
Int temp =-1;
Int CNT = 0;
For (I = 0; I <n; ++ I)
{
If (! Fans [I]. Visit & fans [I]. Start> = temp)
{
Temp = fans [I]. end;
CNT ++;
}
}
Printf ("% d \ n", CNT );
}
// System ("pause ");
Return 0;
}