HEU 5056 新手练级篇

/**************************************
Problem: HEU 5056 新手练级篇
Time: 0.0050 s
Memory: 524 k 
Accepted Time: 2009-04-30 14:27:39
Tips: 插入法排序 
*************************************
*/

#include 
<stdio.h>
int main()
{
    
int n,a,b,sort[120];
    
while(scanf("%d",&n)!=EOF)
    
{
        
int i,j,count=1;
        
for(i=1;i<=n;i++)
        
{
            scanf(
"%d%d",&a,&b);
            
if(a<=100)
            
{
                
if(count==1)sort[1]=b;
                
else
                
{
                    sort[
0]=b;
                    
for(j=count-1;sort[j]<b;j--)
                    sort[j
+1]=sort[j];
                    sort[j
+1]=b;
                }

                count
++;
            }

        }

        
int sum=100,count1=0;
        
for(i=1;i<count;i++)
        
{
            sum
-=sort[i];
            count1
++;
            
if(sum<=0)break;
        }

        
if(sum>0)count1+=sum;
        printf(
"%d\n",count1);
    }

    
return 0;
}

posted @ 2009-04-30 14:37  主函数  阅读(140)  评论(0编辑  收藏  举报