import java.util.Scanner; import java.util.TreeMap; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); TreeMap<Integer, Integer> map = new TreeMap<>(); int a = sc.nextInt(); int b = sc.nextInt(); for(int i = 0; i < a + b; i ++) { map.put(sc.nextInt(), sc.nextInt()); } for(int i = 0; i < a + b; i ++) { System.out.println(map.firstKey() + " " + map.get(map.firstKey())); map.remove(map.firstKey()); } } } |
Double click to view unformatted code.