Advertisement
daskalot

Untitled

Jan 10th, 2019
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.Scanner;
  3. public class Tester {
  4. public static void main(String[] args) throws IOException {
  5. Scanner cin = new Scanner(System.in);
  6. int n = cin.nextInt();
  7. int[] arr = new int[n+10];
  8. while(n-->0) {
  9. String temp = cin.next();
  10. String helper[] = temp.split(",");
  11. int id = Integer.parseInt(helper[0]), w = Integer.parseInt(helper[3]);
  12. arr[id] = w;
  13. }
  14. String temp = cin.next();
  15. String helper[] = temp.split(",");
  16. int r1 = 0;
  17. for(int i=0;i<helper.length;i++) {
  18. r1 += arr[Integer.parseInt(helper[i])];
  19. }
  20. int r2=0;
  21. temp = cin.next();
  22. helper = temp.split(",");
  23. for(int i=0;i<helper.length;i++) {
  24. r2 += arr[Integer.parseInt(helper[i])];
  25. }
  26. System.out.println(r1+ " " + r2);
  27. cin.close();
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement