| ||||||||||
| 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 | |||||||||
memset不知怎么没用对就错了。。。好几个wa啊。。In Reply To:少写了个等号,郁闷了~ Posted by:huguang123 at 2009-04-24 13:25:05 memset(hotel,0,10002);
换成了for就ac了。。。
我写了几个,还是结构体一次排序最快。
#include <iostream>
int N,ans,past,D,C;
int hotel[10002];
int main(){
while (scanf("%d",&N) && N){
ans=1;
for (int i=0;i<N;i++){
scanf("%d%d",&D,&C);
if (hotel[C]==0 || D < hotel[C])
hotel[C]=D;
}
past=-1;
for (int i=0;i<10002;i++){//error here.
if (hotel[i]==0) continue;
if (past==-1){
past=hotel[i];
continue;
}
if (past>hotel[i]){
past=hotel[i];//这里写错了。
ans++;
// printf("%d%d\n",hotel[i],i);
}
}
printf("%d\n",ans);
memset(hotel,0,10002);
for (int i=0;i<10002;i++)
hotel[i]=0;
// if (hotel[i]!=0)
// printf("%d%d",i,hotel[i]);*/
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator