結果
| 問題 | No.11 カードマッチ | 
| コンテスト | |
| ユーザー |  chiho_miyako | 
| 提出日時 | 2015-04-16 17:44:29 | 
| 言語 | Java (openjdk 23) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 144 ms / 5,000 ms | 
| コード長 | 783 bytes | 
| コンパイル時間 | 2,071 ms | 
| コンパイル使用メモリ | 74,996 KB | 
| 実行使用メモリ | 41,844 KB | 
| 最終ジャッジ日時 | 2024-10-11 19:47:44 | 
| 合計ジャッジ時間 | 5,582 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 19 | 
ソースコード
import java.util.*;
public class Main {
   public static void main(String[] args) throws Exception {
       Scanner koko = new Scanner(System.in);
       long w = koko.nextLong();
       long h = koko.nextLong();
       int n = koko.nextInt();
       int[] s = new int[n];
       int[] k = new int[n];
       for(int i=0; i<n; i++){
           s[i]=koko.nextInt();
           k[i]=koko.nextInt();
       }
       Arrays.sort(s);
       Arrays.sort(k);
       long counts=1;
       long countk=1;
       for(int i=1; i<n; i++){
           if(s[i]!=s[i-1]){
               counts++;
           }if(k[i]!=k[i-1]){
               countk++;
           }
       }
       long a = countk*w;
       long b = h-countk;
       long ans=(a-n)+(counts*b);
       System.out.println(ans);
   }
}
            
            
            
        