結果
問題 |
No.1225 I hate I hate Matrix Construction
|
ユーザー |
![]() |
提出日時 | 2020-09-12 12:33:37 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 184 ms / 2,000 ms |
コード長 | 874 bytes |
コンパイル時間 | 2,191 ms |
コンパイル使用メモリ | 74,204 KB |
実行使用メモリ | 54,672 KB |
最終ジャッジ日時 | 2024-12-31 17:31:12 |
合計ジャッジ時間 | 9,696 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 35 |
ソースコード
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); } }