結果
問題 | No.11 カードマッチ |
ユーザー | SagToki |
提出日時 | 2018-06-04 10:17:06 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 148 ms / 5,000 ms |
コード長 | 1,770 bytes |
コンパイル時間 | 5,698 ms |
コンパイル使用メモリ | 77,532 KB |
実行使用メモリ | 56,064 KB |
最終ジャッジ日時 | 2023-09-12 22:03:14 |
合計ジャッジ時間 | 9,552 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 124 ms
56,064 KB |
testcase_01 | AC | 120 ms
39,484 KB |
testcase_02 | AC | 118 ms
39,404 KB |
testcase_03 | AC | 119 ms
39,364 KB |
testcase_04 | AC | 132 ms
39,796 KB |
testcase_05 | AC | 121 ms
39,420 KB |
testcase_06 | AC | 138 ms
39,488 KB |
testcase_07 | AC | 136 ms
39,948 KB |
testcase_08 | AC | 148 ms
39,924 KB |
testcase_09 | AC | 138 ms
40,280 KB |
testcase_10 | AC | 132 ms
39,816 KB |
testcase_11 | AC | 136 ms
39,716 KB |
testcase_12 | AC | 137 ms
39,636 KB |
testcase_13 | AC | 132 ms
39,692 KB |
testcase_14 | AC | 134 ms
39,536 KB |
testcase_15 | AC | 133 ms
39,552 KB |
testcase_16 | AC | 137 ms
39,604 KB |
testcase_17 | AC | 139 ms
39,932 KB |
testcase_18 | AC | 140 ms
39,596 KB |
ソースコード
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){ long W = Input(1,1000000); long H = Input(1,1000000); long N = Input(1, (int) 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, (int) W)); K.add(Input(1, (int) H)); } long 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 long Processing(long W , long H , long N , ArrayList<Integer> S , ArrayList<Integer> K){ ArrayList<Integer> CountS = new ArrayList<>(new HashSet<>(S)); ArrayList<Integer> CountK = new ArrayList<>(new HashSet<>(K)); long Total = W * H ; long UnmatchW = W - CountS.size(); long UnmatchH = H - CountK.size(); long Result = Total - UnmatchW * UnmatchH - N; return Result; } }