标签:des style blog io ar color os sp for
Description
Input
Output
Sample Input
12 1 3 3 4 0 7 3 8 15 19 15 20 10 15 8 18 6 12 5 10 4 14 2 9 0
Sample Output
5
#include<iostream>
using namespace std;
int main()
{
int n,t,i,j;
int a[100],b[100];
while(cin>>n)
{
if(n==0)
break;
for(i=0;i<n;i++)
cin>>a[i]>>b[i];
for(i=0;i<n;i++) //按结束时间从小到大排序
{
for(j=0;j<n-i-1;j++)
{
if(b[j+1]<b[j])
{
swap(b[j],b[j+1]);
swap(a[j],a[j+1]);
}
}
}
t=1;
for(i=0;i<n;i++)//上一个节目结束的时间与下一个节目开始的时间进行比较
{
for(j=i+1;j<n;j++)
{
if(b[i]<=a[j])
{
t++;
i=j;
}
}
}
cout<<t<<endl;
}
return 0;
}标签:des style blog io ar color os sp for
原文地址:http://blog.csdn.net/phytn/article/details/41822079