본문 바로가기
JAVA 알고리즘

SWEA 6730 장애물 경주 난이도

by 잡다한 저장소 2019. 8. 6.
import java.util.*;
public class Solution {
	 Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int T = sc.nextInt();
		for(int tc=1; tc<=T; tc++) {
			int N = sc.nextInt();
			int[] a = new int[N];
			for(int i=0; i<N; i++) a[i] = sc.nextInt();
			int Up = 0;
			int Down = 0;
			for(int i=0; i<N-1; i++) {
				int d = a[i+1] - a[i];
				if( d > 0 ) {
					if( d > maxUp ) maxUp = d;
					continue;
				}
				if( d < 0 ) {
					if( d < -Down ) Down = -d;
				}
			}
			System.out.format("#%d %d %d\n", tc, Up, Down);
		}
	}
}