1. 숫자들은 정렬한다.
2. ABC 입력 순서에 따라 출력해주면 된다.
3. 어떻게 하면 짧은 코드를 짤 수 있을까? 해서 나온 코드다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
import java.io.*; | |
/** | |
* https://www.acmicpc.net/problem/3047 | |
* BOJ 백준온라인져지 3047 ABC 풀이 | |
*/ | |
public class Main { | |
private static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); | |
private static int memoization[] = new int[16]; | |
private static int arr[][]; | |
private static int N; | |
public static void main(String args[]) throws IOException { | |
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | |
String str1[] = br.readLine().split(" "); | |
int arr[] = new int[3]; | |
for (int i = 0; i < 3; i++) arr[i] = Integer.parseInt(str1[i]); | |
Arrays.sort(arr); | |
String str2[] = br.readLine().split(""); | |
for (int i = 0; i < 3; i++) bw.write(arr[str2[i].charAt(0) - 'A'] + " "); | |
bw.flush(); | |
} | |
} |
ABC 성공
시간 제한 | 메모리 제한 | 제출 | 정답 | 맞은 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 128 MB | 2755 | 1542 | 1394 | 58.156% |
문제
세 수 A, B, C가 주어진다. A는 B보다 작고, B는 C보다 작다.
세 수 A, B, C가 주어졌을 때, 입력에서 주어진 순서대로 출력하는 프로그램을 작성하시오.
입력
첫째 줄에 세 수 A, B, C가 주어진다. 하지만, 순서는 A, B, C가 아닐 수도 있다. 세 수는 100보다 작거나 같은 자연수이다. 둘째 줄에는 A, B, C로 이루어진 세 글자가 주어지며, 이 순서대로 출력하면 된다.
출력
주어진 세 수를 주어진 출력 순서대로 출력하면 된다.
예제 입력 1
1 5 3 ABC
예제 출력 1
1 3 5
힌트
'IT > 알고리즘' 카테고리의 다른 글
BOJ 백준온라인져지 3020 개똥벌레 풀이 (0) | 2018.05.17 |
---|---|
BOJ 백준온라인져지 1937 욕심쟁이 판다 풀이 (0) | 2018.05.16 |
BOJ 백준온라인져지 14501 퇴사 풀이 (0) | 2018.05.15 |
BOJ 백준온라인져지 1182 부분집합의 합 풀이 (0) | 2018.05.15 |
BOJ 백준온라인져지 1654 랜선 자르기 풀이 (0) | 2018.05.14 |