結果

問題 No.11 カードマッチ
ユーザー SagTokiSagToki
提出日時 2018-06-04 10:02:38
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,737 bytes
コンパイル時間 4,107 ms
コンパイル使用メモリ 78,992 KB
実行使用メモリ 57,252 KB
最終ジャッジ日時 2023-09-12 22:03:23
合計ジャッジ時間 7,377 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,944 KB
testcase_01 AC 126 ms
56,060 KB
testcase_02 AC 125 ms
55,916 KB
testcase_03 AC 125 ms
55,792 KB
testcase_04 WA -
testcase_05 AC 124 ms
55,808 KB
testcase_06 WA -
testcase_07 AC 146 ms
56,028 KB
testcase_08 AC 145 ms
55,612 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 143 ms
55,728 KB
testcase_16 AC 143 ms
55,440 KB
testcase_17 AC 143 ms
55,660 KB
testcase_18 AC 145 ms
55,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.InputMismatchException;

public class CardMatch {
    static Scanner scanner = new Scanner(System.in);
    
    public static void main(String[] args){
        int W = Input(1,1000000);
        int H = Input(1,1000000);
        int N = Input(1,Math.min(W*H,100));
        ArrayList<Integer> S = new ArrayList<>();
        ArrayList<Integer> K = new ArrayList<>();
        for(int i = 0 ; i < N ; i++){
           S.add(Input(1,W));
           K.add(Input(1,H));
        }
        int Result = Processing(W,H,N,S,K);
        System.out.println(Result);
    }
    
    public static int Input(int Min , int Max){
        int Number = scanner.nextInt();
        try{
            if(Number < Min || Number > Max){
                System.out.println(Min + "以上" + Max + "以下の数字で入力してください");
                System.exit(0);
            } 
        }catch(InputMismatchException e){
            System.out.println("数字を入力してください");
            System.exit(0);
        }catch(Exception E){
            System.out.println("想定外のエラーです");
            System.exit(0);
        }
        return Number;
    }
    
    public static int Processing(int W , int H , int N
                                  , ArrayList<Integer> S , ArrayList<Integer> K){
        ArrayList<Integer> CountS = new ArrayList<>(new HashSet<>(S));
        ArrayList<Integer> CountK = new ArrayList<>(new HashSet<>(K));
        int Total = W * H ;
        int UnmatchW = W - CountS.size();
        int UnmatchH = H - CountK.size();
        int Result = Total - UnmatchW * UnmatchH - N;
        return Result;
    }
}
0