結果

問題 No.11 カードマッチ
コンテスト
ユーザー chiho_miyako
提出日時 2015-04-16 17:44:29
言語 Java
(openjdk 26.0.2.1 + ACL)
コンパイル:
javac -J-Duser.language=en -encoding UTF8 -cp /opt/aclib/ac_library.jar _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true -cp .:/opt/aclib/ac_library.jar _class_
結果
AC  
実行時間 75 ms / 5,000 ms
+ 7µs
コード長 783 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,348 ms
コンパイル使用メモリ 86,152 KB
実行使用メモリ 43,904 KB
最終ジャッジ日時 2026-09-14 05:02:17
合計ジャッジ時間 4,251 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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);
   }
}
0