Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Problem04;
- import java.util.Scanner;
- import java.util.TreeMap;
- public class Nuts {
- public static void main(String[] args) {
- // Writing The Input
- Scanner scn = new Scanner(System.in);
- int n = Integer.parseInt(scn.nextLine());
- TreeMap<String, TreeMap<String, int[]>> companies = new TreeMap<>();
- for (int i = 0; i < n; i++) {
- String[] line = scn.nextLine().split("\\s+");
- String company = line[0];
- String nuts = line[1];
- String amount = line[2];
- if (!companies.containsKey(company)) {
- companies.put(company, new TreeMap<>());
- }
- if (!companies.get(company).containsKey(nuts)) {
- companies.get(company).put(nuts,new int[1]);
- }
- // Writing The Output:
- // Expected Output
- //EatYourNuts: almonds-30kg, brazilnuts-15kg
- //KingNuts: almonds-250kg
- //Rois: cashews-14kg, wallnuts-28 kg
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement