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 zhb_msqx at 2007-08-24 12:18:07 on Problem 1877
#include <stdio.h>
#include <iostream>
#include <fstream>
using namespace std;

int height[1000];
int n,m;
int cmp(const void *a1,const void *a2){
	return ( *(int *)a1-*(int *)a2   );
}

void main(){
//	ifstream cin("data.txt");
	int testcase=1;
	while(1){
		cin>>n>>m;
		if(n==0)break;
		memset(height,0,sizeof(height));
		for(int i=0;i<=n*m-1;i++){
			cin>>height[i];
		}
		qsort(height,n*m,sizeof(int),cmp);
		int sum;
		cin>>sum;
		double ave=(double)sum/100;
		for(i=1;i<n*m;i++){
			double tmp=0;
			for(int j=0;j<i;j++){
				tmp+=height[i]-height[j];
			}
			if(ave<=tmp){
				double t=(double)1.0*(tmp-ave)/i;
				printf("Region %d\n",testcase++);
				printf("Water level is %.2lf meters.\n",height[i]-t);
				printf("%.2lf percent of the region is under water.\n",(double)100.0*i/(n*m));
				break;
			}
		}
		
	}

}

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