Apr 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)

This site uses Akismet to reduce spam. Learn how your comment data is processed.