#include
<
stdio.h
>
#include
<
stdlib.h
>
#define
N 50001
struct
Node
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
int
a, b;
}
;
![](/Images/OutliningIndicators/None.gif)
Node d[N];
int
n;
![](/Images/OutliningIndicators/None.gif)
int
cmp(
const
void
*
a,
const
void
*
b )
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
Node
*
ta
=
(Node
*
)a;
Node
*
tb
=
(Node
*
)b;
if
( ta
->
a
==
tb
->
a )
return
ta
->
b
-
tb
->
b;
return
ta
->
a
-
tb
->
a;
}
int
main()
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
scanf(
"
%d
"
,
&
n);
for
(
int
i
=
0
; i
<
n;
++
i ) scanf(
"
%d%d
"
,
&
d[i].a,
&
d[i].b );
qsort( d, n,
sizeof
( d[
0
] ), cmp );
int
min
=
d[
0
].a, max
=
d[
0
].b;
for
(
int
i
=
1
; i
<
n;
++
i )
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
if
( d[i].a
>
max )
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
printf(
"
%d %d\n
"
, min, max );
min
=
d[i].a, max
=
d[i].b;
}
else
if
( d[i].b
>
max ) max
=
d[i].b;
}
printf(
"
%d %d\n
"
, min, max );
return
0
;
}
posted on 2008-10-29 23:01
Darren 阅读(207)
评论(0) 编辑 收藏 引用 所属分类:
图论