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

为什么老是WA,大家帮忙看看!测试数据我测试一下是对的啊。

Posted by 918 at 2010-02-10 10:47:44 on Problem 2497
#include<stdio.h>
void main()
{
	int 
	num,min,m,n,p,q,i,j,temp,k,a[24],sum_s,pro_s,score_s;
	scanf("%d",&num);
	for(i=0;i<num;i++)
	{sum_s=pro_s=score_s=0;
	scanf("%d %d",&m,&n);
	for(j=0;j<n;j++)
	scanf("%d",&a[j]);
	for(p=0;p<n-1;p++)
	{min=p;
	for(q=p+1;q<=n-1;q++)
	if(a[q]<a[min])  min=q;
    temp=a[p];a[p]=a[min];a[min]=temp;
	}
	for(j=0;sum_s<=m;j++)
	sum_s+=a[j];
	j-=1;
	pro_s=j;
	for(k=0;k<j;k++)
	score_s+=a[k]*(j-k);
    printf("Scenario #%d:\nSteve wins with %d solved problems and a score of %d.\n\n",i+1,pro_s,score_s);
	}
}
	
	
	
	
	
	
	
   

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