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 3233313048 at 2016-05-20 22:04:28 on Problem 1852
#include<cstdio>
int max(int a,int b)
{
	if (a>b) return a;
	else return b;
}
int min(int a,int b)
{
	if (a<b) return a;
	else return b;
}
int l,n;
int x[1000000];
void solve()
{
	int mint=0,maxt=0;
	for (int i=0;i<n;i++)
	{
		mint=max(mint,min(x[i],l-x[i]));
		maxt=max(maxt,max(x[i],l-x[i]));
	}
	printf("%d %d\n",mint,maxt);
}
int main()
{
	int k;
	scanf("%d",&k);
	for (int i=1;i<=k;i++)
	{
	scanf("%d%d",&l,&n);
	for (int j=0;j<n;j++) scanf("%d",&x[j]);
	solve();
	}
	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