結果

問題 No.130 XOR Minimax
コンテスト
ユーザー 37zigen
提出日時 2016-11-24 19:03:16
言語 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_
結果
WA  
実行時間 -
コード長 875 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,664 ms
コンパイル使用メモリ 87,400 KB
実行使用メモリ 63,652 KB
最終ジャッジ日時 2026-09-30 19:22:20
合計ジャッジ時間 15,530 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 RE * 2
other AC * 15 WA * 3 RE * 3
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

package yukicoder;

import java.util.*;

public class Q130 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		for (int i = 0; i < n; ++i) {
			a[i] = sc.nextLong();
		}
		Arrays.sort(a);
		long ans = 0;
		for (int t = 0; t < 100; ++t) {
			for (long i = 32; i >= 0; --i) {// 3=1,1,
				if ((a[n - 1] & (1L << i)) > 0) {
					long[] tmp = Arrays.copyOf(a, n);
					long tmpMax = 0;
					for (int j = 0; j < n; ++j) {
						tmp[j] = a[j] ^ (1L << i);
						tmpMax = Math.max(tmpMax, tmp[j]);
					}
					if (tmpMax == a[n - 1])
						throw new AssertionError();
					if (tmpMax <= a[n - 1]) {
						if ((ans & (1L << i)) > 0)
							throw new AssertionError();
						ans |= 1L << i;
						a = tmp;
						Arrays.sort(a);
						break;
					}
				}
			}
		}
		System.out.println(a[n - 1]);

	}
}
0