結果

問題 No.11 カードマッチ
ユーザー holegumaholeguma
提出日時 2015-08-07 11:37:11
言語 Java21
(openjdk 21)
結果
AC  
実行時間 121 ms / 5,000 ms
コード長 847 bytes
コンパイル時間 2,322 ms
コンパイル使用メモリ 78,040 KB
実行使用メモリ 46,868 KB
最終ジャッジ日時 2024-04-20 01:06:47
合計ジャッジ時間 4,639 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
36,932 KB
testcase_01 AC 54 ms
37,072 KB
testcase_02 AC 54 ms
36,612 KB
testcase_03 AC 55 ms
37,152 KB
testcase_04 AC 111 ms
43,020 KB
testcase_05 AC 54 ms
37,048 KB
testcase_06 AC 94 ms
46,868 KB
testcase_07 AC 67 ms
40,352 KB
testcase_08 AC 101 ms
45,172 KB
testcase_09 AC 114 ms
46,720 KB
testcase_10 AC 118 ms
46,260 KB
testcase_11 AC 115 ms
46,364 KB
testcase_12 AC 121 ms
46,636 KB
testcase_13 AC 104 ms
46,768 KB
testcase_14 AC 109 ms
43,032 KB
testcase_15 AC 57 ms
37,092 KB
testcase_16 AC 57 ms
37,264 KB
testcase_17 AC 57 ms
37,148 KB
testcase_18 AC 57 ms
37,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null){
int w=Integer.parseInt(line);
int h=Integer.parseInt(br.readLine());
int cnt=0;
int matchcnt=0;
int[] app=new int[h+1];
HashMap<Integer,Integer> dic=new HashMap<Integer,Integer>();
int n=Integer.parseInt(br.readLine());
for(int i=0;i<n;i++){
line=br.readLine();
String[] values=line.split(" ");
int s=Integer.parseInt(values[0]);
int k=Integer.parseInt(values[1]);
if(!dic.containsKey(s)){
dic.put(s,1);
}
else{
dic.put(s,dic.get(s)+1);
}
if(app[k]==0){
app[k]=1;
cnt++;
}
}
for(int i=1;i<=w;i++){
if(dic.containsKey(i)){
matchcnt+=h-dic.get(i);
}
else{
matchcnt+=cnt;
}
}
System.out.println(matchcnt);
}
}
}
0