結果

問題 No.698 ペアでチームを作ろう
ユーザー masashi0217masashi0217
提出日時 2021-02-19 07:59:11
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 592 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 11,576 KB
実行使用メモリ 22,324 KB
最終ジャッジ日時 2023-10-13 16:29:05
合計ジャッジ時間 3,160 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,160 KB
testcase_01 AC 80 ms
15,136 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
arr = [*0..(n/2)-1]
max = 0
arr.repeated_permutation(n) do |i|
    ans = 0
    hash = Hash.new(0)
    i.each do |j|
        hash[j] += 1
    end
    ok = true
    i.each do |k|
        if hash[k] != 2
            ok = false
        end
    end
    if ok
        group = Array.new(n/2).map{Array.new()}
        #p group
        i.each_with_index do |item,index|
            group[item] << a[index]
        end
        ans = 0
        group.each do |i,j|
            ans += i ^ j
        end
    end
    max = [max,ans].max
end
puts max
0