結果

問題 No.130 XOR Minimax
ユーザー koyumeishikoyumeishi
提出日時 2015-02-11 06:08:16
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 730 bytes
コンパイル時間 554 ms
コンパイル使用メモリ 76,240 KB
実行使用メモリ 5,500 KB
最終ジャッジ日時 2023-09-05 23:10:02
合計ジャッジ時間 3,068 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 47 ms
5,336 KB
testcase_05 AC 66 ms
5,500 KB
testcase_06 AC 57 ms
5,332 KB
testcase_07 WA -
testcase_08 AC 56 ms
5,492 KB
testcase_09 AC 9 ms
4,376 KB
testcase_10 AC 13 ms
4,376 KB
testcase_11 AC 50 ms
5,056 KB
testcase_12 WA -
testcase_13 AC 40 ms
4,652 KB
testcase_14 AC 48 ms
4,920 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 38 ms
4,380 KB
testcase_17 AC 39 ms
4,492 KB
testcase_18 WA -
testcase_19 AC 41 ms
5,072 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 10 ms
4,380 KB
testcase_23 AC 4 ms
4,380 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=0; k<31; 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