結果
| 問題 |
No.130 XOR Minimax
|
| コンテスト | |
| ユーザー |
tenten
|
| 提出日時 | 2020-10-26 17:12:45 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 852 bytes |
| コンパイル時間 | 2,309 ms |
| コンパイル使用メモリ | 74,292 KB |
| 実行使用メモリ | 55,680 KB |
| 最終ジャッジ日時 | 2024-07-21 21:29:15 |
| 合計ジャッジ時間 | 15,446 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 2 WA * 19 |
ソースコード
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);
}
}
tenten