4월 042012
 

개미가 부디칠 경우 통과한다고 보고 작성.,

 

속도는 O(n)

import java.util.Scanner;

public class P1852 {

	/**
	 * @param args
	 */

	public static void main(String[] args) {
		int testcase;
		Scanner scan = new Scanner(System.in);

		testcase = scan.nextInt();

		while (testcase– > 0)
		{
			int l = scan.nextInt();
			int n = scan.nextInt();

			int max = 0;
			int min = 0;

			for (int i=0; i<n; i++)
			{
				int t = scan.nextInt();

				max = Math.max(max, Math.max(l-t, t));
				min = Math.max(min, Math.min(l-t, t));
			}

			System.out.println(min + ” ” + max);
		}
	}
}

 


 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

이 사이트는 스팸을 줄이는 아키스밋을 사용합니다. 댓글이 어떻게 처리되는지 알아보십시오.