Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.Scanner;
- public class Tester {
- public static void main(String[] args) throws IOException {
- Scanner cin = new Scanner(System.in);
- int n = cin.nextInt();
- int[] arr = new int[n+10];
- while(n-->0) {
- String temp = cin.next();
- String helper[] = temp.split(",");
- int id = Integer.parseInt(helper[0]), w = Integer.parseInt(helper[3]);
- arr[id] = w;
- }
- String temp = cin.next();
- String helper[] = temp.split(",");
- int r1 = 0;
- for(int i=0;i<helper.length;i++) {
- r1 += arr[Integer.parseInt(helper[i])];
- }
- int r2=0;
- temp = cin.next();
- helper = temp.split(",");
- for(int i=0;i<helper.length;i++) {
- r2 += arr[Integer.parseInt(helper[i])];
- }
- System.out.println(r1+ " " + r2);
- cin.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement