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
欢迎参加IJCAI 2020麻将智能体竞赛,大奖等你拿!Welcome to IJCAI 2020 Mahjong AI competition with amazing prizes!

ft~~~~~~~~~~~~~~原来是快排的问题,换了sort就能过

Posted by sunmoonstar_love at 2005-07-20 20:07:19 on Problem 2497
In Reply To:这就像咱们比赛,先在简单的,肯定是最优,但是不知为什么,只做出steve的WA, 三个人都写的话就AC,帮我看看 Posted by:sunmoonstar_love at 2005-07-20 19:40:30
> #include <stdio.h>
> #include <stdlib.h>
> #include <iostream>
> using namespace std;
> int cmp1(int* a, int* b)
> {
>     if(*a<*b)
>         return 1;
>     return 0;
> }
> int cmp2(int* a, int* b)
> {
>     if(*a>*b)
>         return 1;
>     return 0;
> }
>     
> int bill[25],steve[25],linus[25],s1,s2,s3,i,j,k,test,sce,minute,problem,score1,score2,score3;
> int main()
> {
>     scanf("%d",&test);
>     for(sce=1; sce<=test; sce++)
>     {
>         scanf("%d%d",&minute,&problem);
>         for(i=0; i<problem; i++)
>         {
>             scanf("%d",&bill[i]);
>             steve[i] = linus[i] = bill[i];
>         }    
>         qsort(steve,problem,sizeof(int),(int(*)(const void*, const void*))cmp2);
>         for(i=1; i<problem; i++)
>         {
>             steve[i] += steve[i-1];
>             linus[i] += linus[i-1];
>             bill[i] += bill[i-1];
>         }
>         s1 = s2 = s3 = score1 = score2 = score3 = 0;
>         for(i=0; i<problem; i++)
>         {
>             if(steve[i]<=minute)
>             {
>                 score2 += steve[i];
>                 s2++;
>             }  
>             else 
>                 break;
>         }
>         printf("Scenario #%d:\nSteve wins with %d solved problems and a score of %d.\n\n",sce,s2,score2);
>             
>     }
>     return 0;    
> }    

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