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

是不是有问题啊?谁能帮我看一下,怎么回事啊?

Posted by tempor at 2008-08-06 19:24:59 on Problem 1678
#include <iostream>
#include <algorithm>
using namespace std;

int number[1000];
int main()
{
	int tcase, score[2];
	int n, a, b, minTag, pre, turn;
	cin>>tcase;
	int i, j;
	bool end;
	while(tcase--)
	{
		cin>>n>>a>>b;
		for(i = 0; i < n; i++)
			cin>>number[i];
		score[0] = score[1] = 0;
		sort(number, number+n);
		for(i = n-1; (i >= 0) && (number[i] > b); i--)
			;	
		if((i < 0) || (number[i] < a))
		{
			cout<<"0"<<endl;
			break;	
		}
		pre = number[i];
		minTag = i;
		turn = 1;
		score[0] += pre;
		end = false;
		while(!end)
		{
			end = true;
			for(i = n-1; (i > minTag) && (number[i]-pre) > b; i--)
				;
			if((i <= minTag) || ((number[i]-pre) < a))
				break;	
			score[turn%2] += number[i];
			pre = number[i];
			minTag = i;
			end = false;
			turn++;
		}
		cout<<score[0]-score[1]<<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