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 |
为什么老是WA,大家帮忙看看!测试数据我测试一下是对的啊。#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator