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 qywyh_scut at 2006-08-08 15:03:32 on Problem 1852
Source

Problem Id:1852  User Id:qywyh_scut 
Memory:504K  Time:983MS
Language:C++  Result:Accepted

Source 

 #include <iostream>
#include <algorithm>
using namespace std;

const int MAXN = 1000000;
int ants[MAXN];

int main()
{
	int caseTime;
	int antsN, poleL;
	int i;
	int min, max, tmp1, tmp2;
	cin >> caseTime;
	while (caseTime-- != 0)
	{
		scanf("%d%d", &poleL, &antsN);
		
		max = -1; min = -1;

		for (i=0; i<antsN; i++)
		{
			cin >> ants[i];
			tmp1 = ants[i] > poleL-ants[i] ? ants[i] : poleL-ants[i];
			tmp2 = ants[i] < poleL-ants[i] ? ants[i] : poleL-ants[i];

			max = max > tmp1 ? max : tmp1;
			min = min > tmp2 ? min : tmp2;
		}
		

		cout << min << ' ' << max << 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