結果

問題 No.699 ペアでチームを作ろう2
ユーザー nebukuro09nebukuro09
提出日時 2018-06-13 10:29:41
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 675 ms / 1,000 ms
コード長 696 bytes
コンパイル時間 748 ms
コンパイル使用メモリ 110,164 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-03 20:24:06
合計ジャッジ時間 8,331 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 3 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 28 ms
4,380 KB
testcase_05 AC 675 ms
4,380 KB
testcase_06 AC 671 ms
4,380 KB
testcase_07 AC 672 ms
4,380 KB
testcase_08 AC 671 ms
4,376 KB
testcase_09 AC 671 ms
4,380 KB
testcase_10 AC 674 ms
4,376 KB
testcase_11 AC 675 ms
4,380 KB
testcase_12 AC 671 ms
4,376 KB
testcase_13 AC 670 ms
4,376 KB
testcase_14 AC 671 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!long).array;
    auto B = (1<<N).iota.filter!(b => b.popcnt == N/2).array;
    long ans = 0;

    foreach (mask; B) {
        int[] X;
        int[] Y;
        foreach (i; 0..N)
            (mask & (1 << i) ? X : Y) ~= i;
        do {
            long tmp = 0;
            foreach (i; 0..N/2)
                tmp ^= (A[X[i]] + A[Y[i]]);
            ans = max(ans, tmp);
        } while (nextPermutation(X));
    }

    ans.writeln;
}
0