| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
哪位大牛给看下哪错了,一直是WA!谢谢!#include <iostream>
#include <stdlib.h>
using namespace std;
typedef struct Node
{
int D;
int C;
}HotelNode;
int main()
{
int cmp( const void *a , const void *b );
HotelNode Hotel[10000];
int t,i,n,p;
cin>>t;
while(t)
{
for(i=0;i<t;i++)
{
cin>>Hotel[i].D>>Hotel[i].C;
}
qsort(Hotel,i,sizeof(Hotel[0]),cmp);
p=0;
i=0;
n=0;
while(i<t)
{
if(i+1<t&&Hotel[i].D==Hotel[i+1].D&&Hotel[i+1].C<Hotel[p].C)
{
p=i+1;
n++;
}
else if(Hotel[i].C<Hotel[p].C)
{
n++;
p=i;
}
i++;
}
cout<<n<<endl;
cin>>t;
}
return 1;
}
int cmp( const void *a , const void *b )
{
struct Node *c = (Node *)a;
struct Node *d = (Node *)b;
if(c->D != d->D) return c->D - d->D;
else return d->C - c->C;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator