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

why?????????wa

Posted by harvey at 2006-09-29 22:10:35 on Problem 3018
#include<iostream.h>
#include<stdlib.h>
#include<memory.h>
double box[500][1000];
double gif[ 1000 ];
double result[ 500 ];
int cmp( const void *a, const void *b )
{	
	return int( (*(double*)a)-(*(double*)b) );

}
bool isBigger( double a[], double b[], long c)
{	
	bool big = false;
	for( long i = 0; i < c; i++ ){
		if( a[i] > b[i] ){
			big = true;
			break;
		}
		if( a[i] < b[i] ){
			big = false;
			break;
		}
	}
	return big;		
}
bool bigger( double a[],double b[],long c)
{	
	for( int i = 0; i < c; i++ )
		if( a[i] <= b[i] )break;
	if( i == c )
		return true;
	return false;
}
int main()
{	
	long n,d,k;
	double count;
	double max=0;
	while( cin >> n >> d ){
		max=0;
		memset(result,0,500 );
		count=0;
		long i = 0;
		for( i = 0; i < d; i++ )
			cin >> gif[i];
		qsort(gif,d,sizeof( int ),cmp );
		for( i = 0; i < n; i++ ){
			for( long j = 0; j < d; j++ )
				cin >> box[i][j];
			qsort(box[i],d,sizeof( box[0][0] ),cmp );
		}
		
		for( long h = 0; h <= n-1 ; h ++ ){
			for( long kk = 0;kk<n-h-1;kk++){
				if( isBigger(box[kk],box[kk+1],d )){
					for( long mm=0;mm<d;mm++){
						double temp=box[kk][mm];
						box[kk][mm] = box[kk+1][mm];
						box[kk+1][mm] = temp;
					}
				}
			}
		}
		for( k = 0; k < n; k++ ){
			if( bigger(box[k],gif,d) )
				result[k]++;
			max = 0;
			for(long m=0; m < k; m++ ){
				if( bigger(box[k],box[m],d) )
					if( result[ m ] > max )
						max = result[m];
			}
			result[k] += max;
			if( result[k] > count )
				count = result[k];
		}
		if( count == 0 )
			cout <<"Please look for another gift shop!"<<endl;
		else
			cout << count << endl;
	}
	return 0;
}

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