Fork me on GitHub

1852.蚂蚁--变动为静

1->     <- 2  相撞后 为 <- 1   2->                      转化为   <-2        1->
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
	Scanner sc = new Scanner (System.in);
	while(sc.hasNext()) {
		int n = sc.nextInt();
		while(n-->0) {
			int len = sc.nextInt();
			int length = sc.nextInt();
			int arr [] = new int [length];
			int min = 0;
			int max = 0;
			for(int i = 0 ; i < length ; i++) {
				arr[i] = sc.nextInt();
				min = Math.max(min, Math.min(arr[i], len-arr[i]));
				max = Math.max(max, Math.max(arr[i], len-arr[i]));
			}
			System.out.println(min+" "+max);
		}
	}
}
}
posted @ 2019-07-07 22:04  cznczai  阅读(145)  评论(0编辑  收藏  举报