题解——独木桥

#include <iostream>  //核心思想在于穿墙而过

#include <cstdio>

using namespace std;

int main()

{

    int n,l,p,maxv=0,minv=0;

    scanf("%d%d",&l,&n);

    for(int i=1;i<=n;i++)

    {

        scanf("%d",&p);

        maxv=max(maxv,max(l-p+1,p));  //最多需要多少时间

        minv=max(minv,min(l-p+1,p));   //最少需要多少时间(最后取最大值是因为:最后一个离桥的士兵决定了最少需要多少时间)

    }

    printf("%d %d",minv,maxv);

    return 0;

}

 

 

这篇文章,是又一个故事的结束...
lazy's story is continuing.
原文地址:https://www.cnblogs.com/Hello-world-hello-lazy/p/13497833.html