알고리즘/swea
6730. 장애물 경주 난이도
베리영young
2024. 7. 8. 18:29
사용 알고리즘: 구현
사용 언어: java
package swea;
import java.io.*;
import java.util.*;
public class Solution_swea_6730_장애물경주난이도 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int testcase = sc.nextInt();
for (int t = 1; t <= testcase; t++) {
int n = sc.nextInt();
int[] nemoes = new int[n];
for (int i = 0; i < n; i++) {
nemoes[i] = sc.nextInt();
}
int goUp = 0;
int goDown = 0;
for (int i = 0; i < n-1; i++) {
int gap = nemoes[i+1] - nemoes[i];
goUp = Math.max(goUp, gap);
goDown = Math.min(goDown, gap);
}
System.out.println("#"+t+" "+goUp+" "+Math.abs(goDown));
}
}
}
물D3라고 한다.