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

这个是标程,hawk快来删

Posted by c0500448264 at 2005-07-20 19:47:17 on Problem 2497
In Reply To:Re:这就像咱们比赛,先在简单的,肯定是最优,但是不知为什么,只做出steve的WA, 三个人都写的话就AC,帮我看看 Posted by:dyson at 2005-07-20 19:46:30
> /**********************************************************************
>  * 
>  * First of all it should be clear that Steve will always win, since he
>  * has the best strategy. The others will never beat him and even if
>  * they tie the applepie lets Steve win anyway. So we only concentrate
>  * on Steve. This is a little simulation problem, we just have to do
>  * what Steve would do. Sort the problems by increasing difficulty and
>  * then solve them in this order until time runs out, counting the number
>  * of solved problems and keeping track of the score.
>  * 
>  **********************************************************************/
> 
> #include <iostream>
> #include <algorithm>
> using namespace std;
> 
> int main () {
>   int SC;
>   cin >> SC;
>   for( int S=1; S<=SC; S++ ){
>     cout << "Scenario #" << S << ":" << endl;
>     
>     //--- Read the test case.
>     int m, p;
>     cin >> m >> p;
>     int t[24];
>     for( int i=0; i<p; i++ )
>       cin >> t[i];
>     
>     //--- Sort.
>     sort( t, t+p );
>     
>     //--- Analyze.
>     int solved = 0, score = 0, sum = 0;
>     for( int i=0; i<p; i++ ){
>       sum += t[i];
>       if( sum <= m ){
> 	solved++;
> 	score += sum;
>       }
>     }
>     
>     //--- Answer.
>     cout << "Steve wins with " << solved << " solved problems and a score of " << score << "." << endl << endl;
>   }
> }
> 
> 看到的牛人写的;
> 不过注意要CE的哦;

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