일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 프로그래머스
- useState
- 코딩테스트 고득점 Kit 완전탐색
- 데이터모델링과마이닝
- 자바
- codesandbox
- 디자인 패턴
- Java
- vanillaJS
- 리액트
- NextJS
- 백준
- 코틀린
- react hook
- 프로그래머스 자바
- React JS
- 코딩테스트 고득점 Kit
- react
- useEffect
- 자바스크립트
- 프로그래밍 언어론
- 컴퓨터 네트워크
- JavaScript
- websocket
- design pattern
- 리액트 훅
- 프로그래머스 완전탐색
- 자바 공부
- 장고
- react firebase
Archives
- Today
- Total
기록하는 개발자
[백준][JAVA] 1620 : 나는야 포켓몬 마스터 이다솜 본문
728x90
https://www.acmicpc.net/problem/1620
1620번: 나는야 포켓몬 마스터 이다솜
첫째 줄에는 도감에 수록되어 있는 포켓몬의 개수 N이랑 내가 맞춰야 하는 문제의 개수 M이 주어져. N과 M은 1보다 크거나 같고, 100,000보다 작거나 같은 자연수인데, 자연수가 뭔지는 알지? 모르면
www.acmicpc.net
import java.util.HashMap;
import java.util.Scanner;
public class Main {
public static void main(String []args) {
Scanner sc=new Scanner(System.in);
int N=sc.nextInt(), M=sc.nextInt();
HashMap<String, Integer> map = new HashMap<>();
String []arr=new String[N];
for(int i=0; i<N; i++){
String s= sc.next();
arr[i]=s;
map.put(s, i+1);
}
for(int i=0; i<M; i++){
if(sc.hasNextInt()) System.out.println(arr[sc.nextInt()-1]);
else System.out.println(map.get(sc.next()));
}
}
}
728x90
'Algorithm' 카테고리의 다른 글
[백준][JAVA] 1874 : 스택 수열 (0) | 2021.07.11 |
---|---|
[백준][JAVA] 10828 : 스택 (0) | 2021.07.11 |
[백준][JAVA] 10816: 숫자 카드2 (0) | 2021.07.11 |
[백준][JAVA] 11726: 2×n 타일링 (0) | 2021.07.11 |
[백준][JAVA] 9095: 1, 2, 3 더하기 (0) | 2021.07.11 |