2017-03-24 00:02:30 -05:00
|
|
|
// Author: Rodney Shaghoulian
|
2018-07-27 16:45:56 -07:00
|
|
|
// Github: github.com/RodneyShag
|
|
|
|
|
// HackerRank: hackerrank.com/RodneyShag
|
2017-03-24 00:02:30 -05:00
|
|
|
|
|
|
|
|
import java.io.BufferedReader;
|
|
|
|
|
import java.io.InputStreamReader;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
|
|
// Performance Improvements:
|
|
|
|
|
// - used BufferedReader instead of Scanner: https://www.hackerrank.com/challenges/countingsort4/forum/comments/223339
|
|
|
|
|
// - used StringBuffer to do 1 output to console instead of multiple outputs
|
|
|
|
|
|
|
|
|
|
public class Solution {
|
2017-09-11 09:32:17 -07:00
|
|
|
public static void main(String[] args) throws IOException {
|
2017-03-24 00:02:30 -05:00
|
|
|
final int maxValue = 100;
|
2017-04-05 18:42:35 -05:00
|
|
|
|
|
|
|
|
/* Create HashMap with empty "buckets" to put Strings into */
|
|
|
|
|
HashMap<Integer, ArrayList<String>> map = new HashMap<>(maxValue);
|
|
|
|
|
for (int i = 0; i < maxValue; i++) {
|
|
|
|
|
map.put(i, new ArrayList<String>());
|
|
|
|
|
}
|
2017-03-24 00:02:30 -05:00
|
|
|
|
|
|
|
|
/* Save input */
|
|
|
|
|
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
|
|
|
|
|
int n = Integer.parseInt(br.readLine());
|
|
|
|
|
for (int i = 0; i < n; i++) {
|
2017-04-05 18:42:35 -05:00
|
|
|
String [] pair = br.readLine().split(" ");
|
|
|
|
|
int key = Integer.parseInt(pair[0]);
|
|
|
|
|
String value = (i < n/2) ? "-" : pair[1];
|
2017-03-24 00:02:30 -05:00
|
|
|
|
|
|
|
|
ArrayList<String> list = map.get(key);
|
|
|
|
|
list.add(value);
|
|
|
|
|
}
|
|
|
|
|
br.close();
|
|
|
|
|
|
|
|
|
|
/* Print output */
|
|
|
|
|
StringBuffer sb = new StringBuffer();
|
2017-04-05 18:42:35 -05:00
|
|
|
for (int i = 0; i < maxValue; i++) {
|
2017-03-24 00:02:30 -05:00
|
|
|
ArrayList<String> values = map.get(i);
|
|
|
|
|
for (String str : values) {
|
|
|
|
|
sb.append(str + " ");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
System.out.println(sb);
|
|
|
|
|
}
|
|
|
|
|
}
|