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??? the problem of 2287!

Posted by freestyle_zhy at 2007-04-27 14:05:30
I have tested my program on my computer, the output is always right, but when it is judged, it always tells me wrong answer.

the code is as follow:

#include <iostream>
using namespace std;
void bubble(int *items,int count);

int main(){
	
while(1){
	int length;
	cin>>length;
	if(length==0){
		return 0;
	}
	int a[length],b[length];
	for(int i=0;i<length;i++)
		cin>>a[i];
	for(int i=0;i<length;i++)
		cin>>b[i];	
	bubble(a,length);
	bubble(b,length);
		

	int j,money=0,counter=0,i=0;
	for(j=0;j<length;j++){
		for(;i<length;i++){
			if(a[j]>=b[i]){
				counter++;
				if(a[j]>b[i])
					money++;
				i++;
				break;	
			}
		}
	}
	cout<<(money-(length-counter))*200<<endl;

}
	return 0;
}

void bubble(int *items,int count){
	int a,b;
	int t;
	for(a=1;a<count;a++){
		for(b=count-1;b>=a;b--){
			if(items[b-1]<items[b]){
				t=items[b-1];
				items[b-1]=items[b];
				items[b]=t;
			}
		}
	}

}

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