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

数组到底开多大 起初写10005 runtime error 后来

Posted by fredia at 2016-07-31 16:55:03 on Problem 1852
#include<stdio.h>
#include<iostream>
#define inf 0x3f3f3f3f
using namespace std;
int a[1000005];
int max(int a,int b)
{
	return a>b?a:b;
}
int min(int a,int b)
{
	return a<b?a:b;
}
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int mint=-inf;
		int maxt=-inf;
		int l,n;
		cin>>l>>n;
		for(int i=0;i<n;i++)
		 cin>>a[i]; 
		for(int i=0;i<n;i++)
		 {
		 mint=max(mint,min(a[i],l-a[i]));
		 maxt=max(maxt,max(a[i],l-a[i]));}
		 cout<<mint<<" "<<maxt<<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