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

wrong answer, attach the source code, help me

Posted by xuan_oscar at 2010-01-28 03:19:18 on Problem 1018
#include<stdio.h>
#include<stdlib.h>

void caculate(int m[][100][2], int best[][2],int mn[], int n);

void main(){
	int t, n;
        int m[100][100][2], best[101][2];
	int mn[100];
	int i,j;
	best[0][1] = best[0][0] = 0;
	scanf("%d %d", &t, &n);
	while(t-- >0){
		for (i=0;i<n;i++){
		 	scanf("%d", &mn[i]);
			for (j=0;j<mn[i];j++){
				scanf("%d %d", &m[i][j][0], &m[i][j][1]);
			}
		}
		caculate(m,best,mn,n);
	}
	return ;
}

void caculate(int m[][100][2], int best[][2],int mn[], int n){
	int i, j;
	for(i=1;i<=n;i++){
		if (i!=1){
	        	best[i][0] = (best[i-1][0]<m[i-1][0][0])?best[i-1][0]:m[i-1][0][0];}
		else{
			best[i][0] = m[i-1][0][0];
		}	
		best[i][1] = best[i-1][0]+m[i-1][0][1];
		for (j=1;j<mn[i-1];j++){
			if (1.0 *(best[i-1][0]+m[i-1][j][0])/(best[i-1][1]+m[i-1][j][1])
			    > (1.0*best[i][0]/best[i][1])
			){
				best[i][0] = m[i-1][j][0];
				best[i][1] = best[i-1][1]+m[i-1][j][1];
			}
		}
	}
	printf("%.3f\n", (1.0*best[i-1][0]/best[i-1][1]));
}

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