Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
数组到底开多大 起初写10005 runtime error 后来#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator