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

第一次c++写,c++交。纪念一下

Posted by YanBaoC at 2014-06-01 00:28:56 on Problem 1852
#include <iostream>
#include <stdio.h>

using namespace std;
int a[1000001];
int main()
{
    int i,l,n,t,minn,maxx;
    scanf("%d",&t);
    while(t--){
        scanf("%d %d",&l,&n);
        for(i=0;i<n;i++)
            scanf("%d",a+i);
        minn=maxx=0;
        for(i=0;i<n;i++)
            minn=max(minn,min(a[i],l-a[i]));
        for(i=0;i<n;i++)
            maxx=max(maxx,max(a[i],l-a[i]));
        printf("%d %d\n",minn,maxx);
    }
    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