[D3] 순열1 - 9940
성능 요약
메모리: 123,408 KB, 시간: 923 ms, 코드길이: 702 Bytes
제출 일자
2023-11-14 09:08
출처: SW Expert Academy, https://swexpertacademy.com/main/code/problem/problemList.do
import java.util.Scanner;
import java.util.Arrays;
class Solution {
public static void main(String args[]) throws Exception {
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
for(int tc = 1; tc <= T; tc++) {
int n = sc.nextInt();
int[] nums = new int[n];
for(int i = 0; i < n; i++){
nums[i] = sc.nextInt();
}
Arrays.sort(nums);
String result = "Yes";
for(int i = 1; i < n; i++){
if(nums[i] - nums[i-1] != 1){
result = "No";
break;
}
}
System.out.println("#" + tc + " " + result);
}
}
}
'알고리즘 - SWEA > D3' 카테고리의 다른 글
[SW expert Academy] SWEA 9839번 최고의 쌍 자바(Java) (0) | 2023.11.14 |
---|---|
[SW expert Academy] SWEA 9778번 카드 게임 자바(Java) (0) | 2023.11.14 |
[SW expert Academy] SWEA 8457번 알 덴테 스파게티 자바(Java) (0) | 2023.11.13 |
[SW expert Academy] SWEA 3233번 정삼각형 분할 놀이 자바(Java) (0) | 2023.11.13 |
[SW expert Academy] SWEA 6900번 주혁이의 복권 당첨 자바(Java) (1) | 2023.11.13 |