1 00:12-12:12 2 00:12-12:12 14:00-12:00
1 1
跟NYOJ-891类似,区间找点
01.
#include<iostream>
02.
#include<algorithm>
03.
using
namespace
std;
04.
struct
node
05.
{
06.
int
h1,h2,m1,m2;
07.
}b[110];
08.
bool
cmp(node
a1,node a2)
09.
{
10.
return
a1.h2<a2.h2;
11.
}
12.
int
main()
13.
{
14.
int
n;
15.
char
c;
16.
while
(cin>>n)
17.
{
18.
for
(
int
i=0;i<n;i++)
19.
{
20.
cin>>b[i].h1>>c>>b[i].m1>>c>>b[i].h2>>c>>b[i].m2;
21.
b[i].h1=b[i].h1*100+b[i].m1;
22.
b[i].h2=b[i].h2*100+b[i].m2;
23.
if
(b[i].h1>b[i].h2)
24.
swap(b[i].h1,b[i].h2);
25.
}
26.
int
sum=1;
27.
sort(b,b+n,cmp);
28.
for
(
int
i=1;i<n;i++)
29.
{
30.
if
(b[i].h1>b[i-1].h2)
31.
sum++;
32.
else
33.
b[i].h2=min(b[i].h2,b[i-1].h2);
34.
}
35.
cout<<sum<<endl;
36.
}
37.
return
0;
38.
}
原文:http://blog.csdn.net/justesss/article/details/36411917