Submission #2407676


Source Code Expand

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String[] sList = new String[n];
        for (int i = 0; i < n; i++) {
            sList[i] = scanner.next();
        }
        int m = scanner.nextInt();
        String[] mList = new String[m];
        for (int i = 0; i < m; i++) {
            mList[i] = scanner.next();
        }

        Map<String, Integer> resultMap = new HashMap<>();
        for (int i = 0; i < n; i++) {
            if(resultMap.containsKey(sList[i])){
                int tempNum = resultMap.get(sList[i]);
                resultMap.put(sList[i], ++tempNum);
            } else {
                resultMap.put(sList[i], 1);
            }
        }
        for (int i = 0; i < m; i++) {
            if(resultMap.containsKey(mList[i])){
                int tempNum = resultMap.get(mList[i]);
                resultMap.put(mList[i], --tempNum);
            } else {
                continue;
            }
        }
        int result = 0;
        for (Map.Entry<String, Integer> entry : resultMap.entrySet() ) {
           if(result < entry.getValue()){
               result = entry.getValue();
           } else {
               continue;
           }
        }
        System.out.println(result);
    }
}

Submission Info

Submission Time
Task B - Two Colors Card Game
User HiroHuntExp
Language Java8 (OpenJDK 1.8.0)
Score 200
Code Size 1404 Byte
Status AC
Exec Time 99 ms
Memory 21844 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 4
AC × 11
Set Name Test Cases
Sample example_0, example_1, example_2, example_3
All example_0, example_1, example_2, example_3, rand_0, rand_1, rand_2, rand_3, rand_4, rand_5, rand_6
Case Name Status Exec Time Memory
example_0 AC 96 ms 21076 KB
example_1 AC 93 ms 21844 KB
example_2 AC 94 ms 21716 KB
example_3 AC 96 ms 21460 KB
rand_0 AC 98 ms 18644 KB
rand_1 AC 98 ms 19412 KB
rand_2 AC 99 ms 18900 KB
rand_3 AC 98 ms 21716 KB
rand_4 AC 97 ms 19540 KB
rand_5 AC 98 ms 18644 KB
rand_6 AC 97 ms 21588 KB