結果

問題 No.11 カードマッチ
ユーザー spaciaspacia
提出日時 2016-01-08 23:56:47
言語 Java21
(openjdk 21)
結果
AC  
実行時間 78 ms / 5,000 ms
コード長 930 bytes
コンパイル時間 2,699 ms
コンパイル使用メモリ 78,048 KB
実行使用メモリ 55,252 KB
最終ジャッジ日時 2024-04-20 01:12:12
合計ジャッジ時間 4,264 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
49,948 KB
testcase_01 AC 51 ms
50,292 KB
testcase_02 AC 50 ms
50,440 KB
testcase_03 AC 51 ms
50,048 KB
testcase_04 AC 68 ms
53,248 KB
testcase_05 AC 50 ms
50,308 KB
testcase_06 AC 73 ms
55,252 KB
testcase_07 AC 54 ms
50,480 KB
testcase_08 AC 72 ms
53,064 KB
testcase_09 AC 74 ms
55,036 KB
testcase_10 AC 70 ms
52,916 KB
testcase_11 AC 69 ms
53,036 KB
testcase_12 AC 68 ms
53,216 KB
testcase_13 AC 70 ms
53,276 KB
testcase_14 AC 78 ms
53,444 KB
testcase_15 AC 52 ms
50,336 KB
testcase_16 AC 52 ms
50,076 KB
testcase_17 AC 52 ms
50,028 KB
testcase_18 AC 53 ms
50,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

class Main {
	
	public static void out (Object o) {
		System.out.println(o);
	}
	
	public static void main (String[] args) throws IOException {
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		
		int markCnt = Integer.parseInt(br.readLine());
		int maxNum = Integer.parseInt(br.readLine());
		int n = Integer.parseInt(br.readLine());
		int[] marks = new int[markCnt + 1];
		ArrayList<Integer> numList = new ArrayList<Integer>();
		
		for (int i = 0; i < n; i++) {
			String[] line = br.readLine().split(" ");
			int mark = Integer.parseInt(line[0]);
			int num = Integer.parseInt(line[1]);
			
			marks[mark]++;
			if (!numList.contains(num)) {
				numList.add(num);
			}
		}
		
		long ans = 0;
		for (int i = 1; i <= markCnt; i++) {
			if (marks[i] == 0) {
				ans += numList.size();
			} else {
				ans += maxNum - marks[i];
			}
		}
		
		out(ans);
		
	}
}
0