非洲小孩题意有点难懂
2015-03-10 22:12
232 查看
http://acm.nyist.net/JudgeOnline/problem.php?pid=1036
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
struct time
{
int b,e;
}t[105];
int cmp(struct time x,struct time y)
{
return x.e<y.e;
}
int main()
{
int n,i,count,end;
int b1,b2,e1,e2;
char c;
while(~scanf("%d",&n))
{
for(i=0;i<n;i++)
{
scanf("%d%c%d%c%d%c%d",&b1,&c,&b2,&c,&e1,&c,&e2);
t[i].b=b1*100+b2;
t[i].e=e1*100+e2;
if(t[i].b>t[i].e)
swap(t[i].b,t[i].e);
}
sort(t,t+n,cmp);
end=t[0].e;
count=1;
for(i=1;i<n;i++) //¶àÇø¼äÑ¡È¡×îÉÙ¹«¹²µã
{
if(t[i].b>end)
{
end=t[i].e;
count++;
}
}
printf("%d\n",count);
}
return 0;
}
http://acm.nyist.net/JudgeOnline/problem.php?pid=1036
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
struct time
{
int b,e;
}t[105];
int cmp(struct time x,struct time y)
{
return x.e<y.e;
}
int main()
{
int n,i,count,end;
int b1,b2,e1,e2;
char c;
while(~scanf("%d",&n))
{
for(i=0;i<n;i++)
{
scanf("%d%c%d%c%d%c%d",&b1,&c,&b2,&c,&e1,&c,&e2);
t[i].b=b1*100+b2;
t[i].e=e1*100+e2;
if(t[i].b>t[i].e)
swap(t[i].b,t[i].e);
}
sort(t,t+n,cmp);
end=t[0].e;
count=1;
for(i=1;i<n;i++) //¶àÇø¼äÑ¡È¡×îÉÙ¹«¹²µã
{
if(t[i].b>end)
{
end=t[i].e;
count++;
}
}
printf("%d\n",count);
}
return 0;
}
相关文章推荐
- POJ 1036 Gangsters -- 常规dp 题意好难懂啊
- nyoj-1036-非洲小孩
- NYOJ 非洲小孩
- NYOJ 1036 非洲小孩
- nyoj1036 非洲小孩
- nyoj1036 非洲小孩
- nyoj--1036--非洲小孩(区间相交问题)
- POJ 2082 Terrible Sets 51nod 1102 面积最大的矩形 《题意好难懂---<贪心+单调栈>》
- 非洲小孩
- 非洲小孩
- Ningbo [1220] SPY(题目有点难懂,读懂题目题很简单)
- 1036 非洲小孩
- 1036 非洲小孩【贪心打表】
- NYOJ 1036 非洲小孩
- ZOJ 1542//POJ1861这题给的样例有点坑爹啊!木有按照样例输出,居然过了。啥破题啊!样例与实际的题意不符,这是误导了好多孩纸啊!
- NYOJ1036 非洲小孩 【贪心】
- nyoj 1036 非洲小孩 【区间选点】
- 非洲小孩
- nyoj非洲小孩
- NYOJ1036 非洲小孩