장애물 경주 난이도
Updated:
- 단순구현
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
for (int tc = 1; tc <= T; tc++) {
int N = sc.nextInt();
int[] arr = new int[N];
int up = 0;
int down = 0;
int start = sc.nextInt();
for (int i = 0; i < N - 1; i++) {
int save = sc.nextInt();
if (save > start)
up = Math.max(up, save - start);
else if (save < start)
down = Math.max(down, start - save);
start = save;
}
System.out.println("#" + tc + " " + up + " " + down);
}
}
}
Leave a comment