Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:请教只排一次序的算法,我排了两次,1xxxMS

Posted by Huacm56 at 2006-07-27 12:34:56 on Problem 2726
In Reply To:Re:请教只排一次序的算法,我排了两次,1xxxMS Posted by:Huacm56 at 2006-07-27 12:34:27
> 不用排序的算法
> #include<stdio.h>
> int re[10010]={0};
> int main()
> { int N,D,C,i,j,sum,max,right=0,result;
>   while(scanf("%d",&N)&&N)
>    {  for(i=0;i<10010;i++)
>          re[i]=10010; 
>       sum=0;result=1;   
>       for(i=0;i<N;i++)
>        { scanf("%d%d",&D,&C);
>          if(re[D]>C)  re[D]=C;
>          if(right<D)  right=D;
>        }
>       i=0;
>       while(re[i]==10010) i++;
>       max=re[i];
>       for(j=i+1;j<=right;j++)
>           if(re[j]<max)
>                 {result++;max=re[j];}
>       printf("%d\n",result);
>    }
>    return 0;
> }          
46MS

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator