최's 먹공로그
SW expert Academy 5431_민석이의 과제 체크하기 본문
https://www.swexpertacademy.com/main/code/problem/problemDetail.do
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41 |
import java.util.Scanner;
public class Solution_5431_민석이의과제체크하기_최성호 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int T = sc.nextInt(); // test case
for(int tc = 1; tc <= T; tc++) {
int N = sc.nextInt(); // 수강생 수 5
int K = sc.nextInt(); // 제출한 사람 수 3
int[] cnt = new int[N+1]; // 수강생 수의 크기+1의 배열
int[] pass = new int[K+1]; // 제출한 사람 수의 크기+1의 배열
int[] non = new int[N+1]; // 제출안한 사람의 번호 저장하기 위한 배열
for(int i = 1; i <= K; i++) {
pass[i] = sc.nextInt(); // pass = {0 , 2 , 5, 3} 0번째 값은 안씀
}
for(int j = 1; j < pass.length; j++) {
cnt[pass[j]]++; // cnt = {0, 0, 1, 1, 0, 1}
}
for(int k = 1; k <= N; k++) {
if(cnt[k] == 0) {
non[k] = k; // non = {0, 1, 0, 0, 4, 0}
}
}
System.out.print("#" + tc + " ");
for(int l = 1; l < non.length; l++) {
if(non[l] != 0) {
System.out.print(non[l] + " "); // 1, 4 출력
}
}
System.out.println();
} // end of tc
} // end of main
}
|
cs |
'APS' 카테고리의 다른 글
SW expert Academy 1210_[S/W 문제해결 기본] 2일차_Ladder1 (0) | 2019.02.03 |
---|---|
SW expert Academy 1208_[S/W 문제해결 기본]1일차_Flatten (0) | 2019.02.03 |
백준10026_적록색약 (0) | 2019.02.03 |
백준2667_단지번호붙이기 (0) | 2019.02.03 |
백준1182_부분집합의 합 (0) | 2019.02.03 |