結果
問題 |
No.698 ペアでチームを作ろう
|
ユーザー |
|
提出日時 | 2018-09-25 17:05:24 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 458 bytes |
コンパイル時間 | 654 ms |
コンパイル使用メモリ | 66,240 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-04 23:38:36 |
合計ジャッジ時間 | 3,844 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | WA * 12 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:8:16: warning: ‘ans’ may be used uninitialized in this function [-Wmaybe-uninitialized] 8 | int N, ans; | ^~~
ソースコード
#include <iostream> #include <algorithm> #include <vector> using namespace std; int main(void) { int N, ans; cin >> N; vector<int> v(N); for(int i=0; i<N; i++) { cin >> v[i]; } sort(v.begin(), v.end()); do { int sum=0; for(int i=0; i<N/2; i++) { sum += v[i] ^ v[i+N/2]; } ans = max(sum, ans); reverse(v.begin()+ N/2, v.end()); } while(next_permutation(v.begin(), v.end())); cout << ans << endl; cout << v[1] << endl; return 0; }