結果

問題 No.11 カードマッチ
ユーザー holeguma
提出日時 2015-08-07 11:37:11
言語 Java
(openjdk 23)
結果
AC  
実行時間 117 ms / 5,000 ms
コード長 847 bytes
コンパイル時間 2,195 ms
コンパイル使用メモリ 77,480 KB
実行使用メモリ 47,028 KB
最終ジャッジ日時 2024-10-11 19:54:23
合計ジャッジ時間 4,636 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

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