标签:
Ants
Description
Input
Output
Sample Input
2 10 3 2 6 7 214 7 11 12 7 13 176 23 191
Sample Output
4 8 38 207
Source
Source Code:
#include <cstdio> using namespace std; int minVal(int a,int b){ return a<b?a:b; } int maxVal(int a,int b){ return a>b?a:b; } int Position[1000010]; int main() { int n; int L,num; int minTime,maxTime; while(scanf("%d",&n)!=EOF){ while(n--){ scanf("%d%d",&L,&num); for(int i=0;i<num;++i) scanf("%d",&Position[i]); minTime=maxTime=0; for(int i=0;i<num;++i){ minTime=maxVal(minTime,minVal(Position[i],L-Position[i])); maxTime=maxVal(maxTime,maxVal(Position[i],L-Position[i])); } printf("%d %d\n",minTime,maxTime); } } return 0; }
标签:
原文地址:http://www.cnblogs.com/Murcielago/p/4215311.html