您的位置:首页 > 其它

poj-1852

2014-10-24 00:53 218 查看
转换思想 两只蚂蚁碰头反转时 相当于直接从对方身上走过去 直接前进

#include "stdio.h"
#include "string.h"
#include "math.h"
#include "stdlib.h"
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <queue>

using namespace std;

int t;
int main()
{
    cin>>t;
    while (t--)
    {
        int n,m,tt;
        cin>>n>>tt;
        int p;
        int an1=-1000000,an2=-1000000;
        for (int i=1;i<=tt;i++)
            {
                cin>>m;
                an1=max( an1,min( (n-m) ,(n-(n-m)) ) );
                an2=max( an2,max( (n-m) ,(n-(n-m)) ) );
            }
        cout<<an1<<" "<<an2<<endl;
    }
    return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: