#include
<
iostream
>
using
namespace
std;
struct
arr{
int
x,y;
}a[
1000
];
int
n,f[
1000
];
int
cmp(
const
void
*
no1,
const
void
*
no2){
arr
*
nox
=
(arr
*
)no1,
*
noy
=
(arr
*
)no2;
if
(nox
->
x
>
noy
->
x)
return
1
;
else
if
(nox
->
x
<
noy
->
x)
return
-
1
;
else
return
nox
->
y
-
noy
->
y;
}
int
main()
{
scanf(
"
%d
"
,
&
n);
for
(
int
i
=
0
;i
<
n;
++
i) scanf(
"
%d%d
"
,
&
a[i].x,
&
a[i].y);
qsort(a,n,
sizeof
(arr),cmp);
int
MAX
=
0
;
for
(
int
i
=
0
;i
<
n;
++
i){
f[i]
=
a[i].y
-
a[i].x
+
1
;
for
(
int
j
=
i
-
1
;j
>=
0
;
--
j)
if
(a[i].x
>
a[j].y)
if
(f[i]
<
f[j]
+
a[i].y
-
a[i].x
+
1
)
f[i]
=
f[j]
+
a[i].y
-
a[i].x
+
1
;
if
(f[i]
>
MAX) MAX
=
f[i];
}
printf(
"
%d\n
"
,MAX);
return
0
;
}
posted on 2009-05-01 16:30
xfstart07 阅读(286)
评论(0) 编辑 收藏 引用 所属分类:
代码库