結果
| 問題 |
No.699 ペアでチームを作ろう2
|
| ユーザー |
👑 |
| 提出日時 | 2019-07-08 23:49:49 |
| 言語 | Lua (LuaJit 2.1.1734355927) |
| 結果 |
AC
|
| 実行時間 | 597 ms / 1,000 ms |
| コード長 | 1,125 bytes |
| コンパイル時間 | 146 ms |
| コンパイル使用メモリ | 6,816 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-09 19:50:21 |
| 合計ジャッジ時間 | 5,397 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
ソースコード
local mfl, mma = math.floor, math.max
local function getxor(x, y)
local ret = 0
local mul = 1
while(0 < x or 0 < y) do
if((x % 2) + (y % 2) == 1) then
ret = ret + mul
end
x, y, mul = mfl(x / 2), mfl(y / 2), mul * 2
end
return ret
end
local n = io.read("*n")
local a = {}
for i = 1, n do a[i] = io.read("*n") end
local n2 = n / 2
local tot = 1
for i = 1, n2 do
tot = tot * (i * 2 - 1)
end
local box = {}
local maxsum = 0
for i = 0, tot - 1 do
local sum = 0
for k = 1, n do box[k] = 0 end
for j = 1, n2 do
local pos1 = 0
for k = 1, n do
if box[k] == 0 then
box[k] = j
pos1 = k
break
end
end
local div = (n2 + 1 - j) * 2 - 1
local rel_pos = i % div
i = mfl(i / div)
local rel_cnt = 0
for k = 1, n do
if box[k] == 0 then
if rel_cnt == rel_pos then
box[k] = j
local pos2 = k
sum = getxor(sum, a[pos1] + a[pos2])
break
else
rel_cnt = rel_cnt + 1
end
end
end
end
-- print(unpack(box))
maxsum = mma(maxsum, sum)
end
print(maxsum)