Advertisement
Guest User

Untitled

a guest
Aug 25th, 2014
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.66 KB | None | 0 0
  1. import java.util.HashMap;
  2. import java.util.Scanner;
  3. import java.util.TreeMap;
  4.  
  5. public class _04Problem {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner scn = new Scanner(System.in);
  9.         int n = scn.nextInt();
  10.         HashMap<String, TreeMap> orders = new HashMap<String, TreeMap>();
  11.         TreeMap<String, Integer> nameAndAmount = new TreeMap<String, Integer>();
  12.         for (int i = 0; i < n; i++) {
  13.             String customer = scn.next();
  14.             int amount = scn.nextInt();
  15.             String product = scn.nextLine();
  16.             Integer count = nameAndAmoun.get(customer);
  17.             nameAndAmoun.put(customer, count == null? amount : count + amount);
  18.             orders.put(product, nameAndAmoun);
  19.         }
  20.        
  21.     }
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement