Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.HashMap;
- import java.util.Scanner;
- import java.util.TreeMap;
- public class _04Problem {
- public static void main(String[] args) {
- Scanner scn = new Scanner(System.in);
- int n = scn.nextInt();
- HashMap<String, TreeMap> orders = new HashMap<String, TreeMap>();
- TreeMap<String, Integer> nameAndAmoun = new TreeMap<String, Integer>();
- for (int i = 0; i < n; i++) {
- String customer = scn.next();
- int amount = scn.nextInt();
- String product = scn.nextLine();
- orders.put(product, nameAndAmoun);
- Integer count = nameAndAmoun.get(customer);
- nameAndAmoun.put(customer, count == null? amount : count + amount);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement