結果
問題 | No.130 XOR Minimax |
ユーザー | tenten |
提出日時 | 2020-10-26 17:12:45 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 852 bytes |
コンパイル時間 | 2,188 ms |
コンパイル使用メモリ | 71,200 KB |
実行使用メモリ | 67,748 KB |
最終ジャッジ日時 | 2023-09-29 02:41:57 |
合計ジャッジ時間 | 16,490 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 130 ms
55,528 KB |
testcase_02 | AC | 130 ms
55,628 KB |
testcase_03 | AC | 132 ms
55,920 KB |
testcase_04 | AC | 535 ms
65,604 KB |
testcase_05 | AC | 715 ms
66,100 KB |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
ソースコード
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); boolean[][] nums = new boolean[n][31]; for (int i = 0; i < n; i++) { int x = sc.nextInt(); for (int j = 0; j < 31; j++) { nums[i][j] = (x % 2 == 1); x /= 2; } } long ans = 0; for (int i = 0; i < 31; i++) { int count = 0; for (int j = 0; j < n; j++) { if (nums[j][i]) { count++; } } if (count >= n - count) { ans += (1L << i) * (n - count); } else { ans += (1L << i) * count; } } System.out.println(ans); } }