Time Limit: 1000MS | Memory Limit: 30000K | |
Total Submissions: 19494 | Accepted: 8144 |
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
不需要考虑的太多,就算两只蚂蚁碰头了,就接着走.(突然发现POJ不能用万能头文件:哭死)
1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 #include <algorithm> 5 using namespace std; 6 int k[1000000]; 7 int main(){ 8 int n,x,y; 9 scanf("%d",&n); 10 while(n--){ 11 memset(k,0,sizeof(k)); 12 scanf("%d%d",&x,&y); 13 for(int i=0;i<y;i++) 14 scanf("%d",&k[i]); 15 int maxX=0,maxD=0; 16 for(int i=0;i<y;i++){ 17 maxX=max(maxX,min(k[i],x-k[i])); 18 maxD=max(maxD,max(k[i],x-k[i])); 19 } 20 printf("%d %d\n",maxX,maxD); 21 } 22 return 0; 23 }
原文:http://www.cnblogs.com/zllwxm123/p/7384256.html