結果

問題 No.130 XOR Minimax
ユーザー koyumeishikoyumeishi
提出日時 2015-02-11 06:13:47
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 731 bytes
コンパイル時間 558 ms
コンパイル使用メモリ 75,896 KB
実行使用メモリ 4,944 KB
最終ジャッジ日時 2023-09-05 23:10:05
合計ジャッジ時間 2,312 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 25 ms
4,728 KB
testcase_05 AC 53 ms
4,944 KB
testcase_06 AC 37 ms
4,920 KB
testcase_07 WA -
testcase_08 AC 49 ms
4,620 KB
testcase_09 AC 6 ms
4,380 KB
testcase_10 AC 10 ms
4,376 KB
testcase_11 WA -
testcase_12 AC 4 ms
4,376 KB
testcase_13 AC 25 ms
4,376 KB
testcase_14 AC 41 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 29 ms
4,380 KB
testcase_17 AC 30 ms
4,376 KB
testcase_18 AC 32 ms
4,376 KB
testcase_19 AC 38 ms
4,468 KB
testcase_20 AC 19 ms
4,376 KB
testcase_21 AC 41 ms
4,680 KB
testcase_22 WA -
testcase_23 AC 4 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <set>
using namespace std;


int main(){
	long long n;
	cin >> n;
	vector<long long> a(n);

	for(int i=0; i<n; i++){
		cin >> a[i];
	}

	auto get_max = [](vector<long long> &v){
		long long ret = -1;
		for(int i=0; i<v.size(); i++){
			ret = max(ret, v[i]);
		}
		return ret;
	};

	long long ans = 1LL<<60LL;
	for(long long k=32; k>=0; k--){

		ans = min(ans, get_max(a));

		auto b = a;
		for(int i=0; i<n; i++){
			b[i] ^= (1LL<<k);
		}
		long long tmp = get_max(b);
		if(tmp < ans){
			swap(a,b);
			ans = tmp;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}
0