Jun's Development Journey
[BOJ] 1764번 듣보잡 본문
문제
https://www.acmicpc.net/problem/1764
1764번: 듣보잡
첫째 줄에 듣도 못한 사람의 수 N, 보도 못한 사람의 수 M이 주어진다. 이어서 둘째 줄부터 N개의 줄에 걸쳐 듣도 못한 사람의 이름과, N+2째 줄부터 보도 못한 사람의 이름이 순서대로 주어진다. 이름은 띄어쓰기 없이 영어 소문자로만 이루어지며, 그 길이는 20 이하이다. N, M은 500,000 이하의 자연수이다.
www.acmicpc.net
풀이
내 방식대로 풀어서 패스는 받았지만 메모리와 실행 시간이 형편없다... 개선할 수 있는 방법을 더 생각해봐야겠다.
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
|
public class Main {
static Scanner scan = new Scanner(System.in);
static ArrayList<String> list, answer;
static int N,M;
static void solution() {
list = new ArrayList<String>();
N = scan.nextInt();
M = scan.nextInt();
list = new ArrayList<String>();
scan.nextLine();
for(int i=0;i<N+M;i++)
list.add(scan.nextLine());
answer = new ArrayList<String>();
for(int i=0;i<N+M-1;i++) {
answer.add(list.get(i));
i++;
}
}
}
public static void main(String[] args) {
solution();
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
'BOJ > String' 카테고리의 다른 글
[BOJ] 9933번 민균이의 비밀번호 (0) | 2019.08.26 |
---|---|
[BOJ] 3986번 좋은 단어 (0) | 2019.08.26 |
[BOJ] 1475번 방 번호 (0) | 2019.08.22 |
[BOJ] 1157번 단어 공부 (0) | 2019.08.22 |
[BOJ] 1316번 그룹 단어 체커 (0) | 2019.08.22 |