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 |
Re:这就像咱们比赛,先在简单的,肯定是最优,但是不知为什么,只做出steve的WA, 三个人都写的话就AC,帮我看看In Reply To:这就像咱们比赛,先在简单的,肯定是最优,但是不知为什么,只做出steve的WA, 三个人都写的话就AC,帮我看看 Posted by:sunmoonstar_love at 2005-07-20 19:40: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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator