結果

問題 No.1225 I hate I hate Matrix Construction
ユーザー tentententen
提出日時 2020-09-12 12:33:37
言語 Java21
(openjdk 21)
結果
AC  
実行時間 186 ms / 2,000 ms
コード長 874 bytes
コンパイル時間 2,199 ms
コンパイル使用メモリ 71,660 KB
実行使用メモリ 57,944 KB
最終ジャッジ日時 2023-08-30 05:57:21
合計ジャッジ時間 11,477 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,944 KB
testcase_01 AC 125 ms
55,440 KB
testcase_02 AC 126 ms
55,920 KB
testcase_03 AC 135 ms
57,148 KB
testcase_04 AC 186 ms
55,964 KB
testcase_05 AC 141 ms
55,672 KB
testcase_06 AC 184 ms
55,948 KB
testcase_07 AC 145 ms
55,788 KB
testcase_08 AC 158 ms
55,972 KB
testcase_09 AC 178 ms
56,520 KB
testcase_10 AC 176 ms
56,280 KB
testcase_11 AC 184 ms
56,996 KB
testcase_12 AC 181 ms
56,276 KB
testcase_13 AC 152 ms
55,932 KB
testcase_14 AC 134 ms
57,820 KB
testcase_15 AC 183 ms
55,912 KB
testcase_16 AC 183 ms
55,948 KB
testcase_17 AC 184 ms
56,204 KB
testcase_18 AC 183 ms
56,252 KB
testcase_19 AC 169 ms
56,104 KB
testcase_20 AC 149 ms
55,836 KB
testcase_21 AC 178 ms
56,028 KB
testcase_22 AC 181 ms
56,228 KB
testcase_23 AC 181 ms
56,648 KB
testcase_24 AC 178 ms
56,084 KB
testcase_25 AC 172 ms
56,352 KB
testcase_26 AC 167 ms
55,940 KB
testcase_27 AC 125 ms
55,964 KB
testcase_28 AC 181 ms
56,536 KB
testcase_29 AC 176 ms
56,536 KB
testcase_30 AC 180 ms
55,584 KB
testcase_31 AC 180 ms
56,472 KB
testcase_32 AC 182 ms
55,960 KB
testcase_33 AC 182 ms
56,332 KB
testcase_34 AC 185 ms
57,944 KB
testcase_35 AC 186 ms
56,700 KB
testcase_36 AC 183 ms
55,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
    	int ans = 0;
    	int xOne = 0;
    	int xTwo = 0;
    	for (int i = 0; i < n; i++) {
    	    int x = sc.nextInt();
    	    if (x == 1) {
    	        xOne++;
    	    } else if (x == 2) {
    	        xTwo++;
    	        ans += n;
    	    }
    	}
    	int yOne = 0;
    	int yTwo = 0;
    	for (int i = 0; i < n; i++) {
    	    int x = sc.nextInt();
    	    if (x == 1) {
    	        yOne++;
    	    } else if (x == 2) {
    	        yTwo++;
    	        ans += n - xTwo;
    	    }
    	}
    	if (xTwo == 0 && yTwo == 0) {
    	    ans += Math.max(xOne, yOne);
    	} else if (xTwo == 0) {
    	    ans += yOne;
    	} else if (yTwo == 0) {
    	    ans += xOne;
    	}
    	System.out.println(ans);
	}
}
0