poj1852

简单题

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

int l, n;

void input()
{
    int earliest, latest;
    scanf("%d%d", &l, &n);
    latest = 0;
    earliest = 0;
    for (int i = 0; i < n; i++)
    {
        int a;
        scanf("%d", &a);
        earliest = max(earliest, min(a, l - a));
        latest = max(latest, max(a, l- a));
    }
    printf("%d %d\n", earliest, latest);
}

int main()
{
    int t;
    scanf("%d", &t);
    while (t--)
    {
        input();
    }
    return 0;
}
View Code

 

posted @ 2013-06-13 20:12  金海峰  阅读(118)  评论(0编辑  收藏  举报