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 ,noip测试数据都过了???

Posted by redbox at 2007-01-07 01:41:08 on Problem 1928
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
 


int comp(const void *a,const void *b){
	return *(int*)b-*(int*)a;
}

int main(){
	int n;
int a,b,c;
int data[3000][3]={0};
int time={0};
int t;
int h=0;
int sum=0;
	int i,j;
	
scanf("%d",&n);
while(n--){
	h=0;
	sum=0;
	time=0;
	scanf("%d %d %d",&a,&b,&c);

	for( i=1;i<=a;i++)
		for(j=1;j<=b;j++){
			scanf("%d",&t);
			if(t>0) {
			data[h][0]=t;
			data[h][1]=i;
			data[h++][2]=j;
			}
		}
	qsort(data,3000,3*sizeof(int),comp);
	time=data[0][1]+1;	
	for(i=1;i<h;i++){
		
		if((time+data[i-1][1])<=c) {
		sum+=data[i-1][0];
		time=time+abs(data[i][1]-data[i-1][1])+abs(data[i][2]-data[i-1][2])+1;		
		}
		else break;
	
	}
   
   printf("%d\n",sum);

}
}

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