Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- 코딩테스트
- MySQL
- BFS
- BOJ
- math
- 시뮬레이션
- greedy
- 투포인터
- SQL
- SWEA
- binary search
- 백준
- 문제풀이
- 코테
- 문자열
- 문제해결
- 러닝일지
- COS PRO
- 자바
- 건강
- db
- dfs
- 이분탐색
- 프로그래머스
- 알고리즘
- 운동기록
- priorityqueue
- DP
- oracle
- Java
Archives
- Today
- Total
슈콩
[BOJ] 백준 10815 숫자 카드 본문
[문제]
https://www.acmicpc.net/problem/10815
[소스 코드]
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
StringBuilder sb = new StringBuilder();
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
int n = Integer.parseInt(br.readLine());
HashMap<Integer,Integer> hm = new HashMap<>();
st = new StringTokenizer(br.readLine());
for(int i=0;i<n;i++) {
int x = Integer.parseInt(st.nextToken());
if(!hm.containsKey(x)){
hm.put(x, 1);
}
else {
int v = hm.get(x);
hm.put(x, v+1);
}
}
int m = Integer.parseInt(br.readLine());
st = new StringTokenizer(br.readLine());
for(int i=0;i<m;i++) {
int x = Integer.parseInt(st.nextToken());
if(hm.containsKey(x)) {
sb.append(hm.get(x) + " ");
}
else {
sb.append(0 +" ");
}
}
System.out.println(sb);
}
}'Algorithms > Baekjoon' 카테고리의 다른 글
| [BOJ] 백준 11559 Puyo Puyo (0) | 2025.09.17 |
|---|---|
| [BOJ] 백준 12015 가장 긴 증가하는 부분 수열 2 (0) | 2025.09.17 |
| [BOJ] 백준 1654 랜선 자르기 (0) | 2025.09.16 |
| [BOJ] 백준 2295 세 수의 합 (0) | 2025.09.16 |
| [BOJ] 백준 18870 좌표 압축 (0) | 2025.09.16 |