Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
关键在于问题的转化。。。蚂蚁相遇时的掉头等价于穿过。。。明白这一点问题就很简单了 #include<cstdio> #include<algorithm> using namespace std; int main() { int len, n, i, t, pos, longest, shortest, temp; scanf("%d", &t); while( t-- ) { scanf("%d%d", &len, &n); for( i=0, longest=0, shortest=0; i<n; i++) { scanf("%d", &pos); temp = max(pos, len-pos); longest = max(longest, temp); temp = min(pos, len-pos); shortest = max(shortest, temp); } printf("%d %d\n", shortest, longest); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator