一道acm题,会场安排,总是wrong answer,求助啊

Problem description
假设要在足够多的会场里安排一批活动,并希望使用尽可能少的会场。

Input
第一行有1 个正整数k,表示有 k个待安排的活动。接下来的k行中,每行有 2个正整数,分别表示 k个待安排的活动开始时间和结束时间。时间以0点开始的分钟计。 (k < 10000)

Output
将编程计算出的最少会场数输出。

Sample Input
5
1 23
12 28
25 35
27 80
36 50

Sample Output
3

代码
#include
using namespace std;

int main()
{
int n;
cin >> n;
if(n {
int *Start = new int[n];
int *End = new int[n];
bool *had = new bool[n];
for(int i=0;i {
cin>>Start[i]>>End[i];
had[i]=0;
if(Start[i]<0||End[i]<=Start[i])
{return 0;}
}

//排序
for (int i = 0; i < n; i++)
{
    for (int j = i + 1; j < n; j++)
    {
        if (End[i]>End[j])
        {
            int temp = End[j];
            End[j] = End[i];
            End[i] = temp;
            temp = Start[j];
            Start[j] = Start[i];
            Start[i] = temp;
        }
    }
}

int count=0;
int hall;
while(count!=n)

{
int time=-1;
hall++;
for(int i =0;i {
if(had[i]==0&&Start[i]>time)
{
had[i]=1;
time = End[i];
count++;
}
}
}
cout<<hall;
}
return 0;
}

http://blog.csdn.net/iamalasca/article/details/7537562