結果
問題 |
No.130 XOR Minimax
|
ユーザー |
![]() |
提出日時 | 2015-02-11 06:13:47 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 731 bytes |
コンパイル時間 | 618 ms |
コンパイル使用メモリ | 76,684 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-23 18:29:30 |
合計ジャッジ時間 | 2,128 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 WA * 4 |
ソースコード
#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; }