n = gets.chomp.to_i a = gets.chomp.split(" ").map(&:to_i) bit = 1 << n max = 0 dp = Array.new(1<> j if ij & 1 == 1 team += 1 end end next if team % 2 == 1 #print "iは"+"#{i}" + " "+" teamは" + "#{team}" + "\n" 0.upto(n-2) do |x| next if 1 << x & i != 0 (x+1).upto(n-1) do |y| next if 1 << y & i != 0 xx = 1 << x yy = 1 << y dp[i|xx|yy] = [dp[i|xx|yy],dp[i] + (a[x] ^ a[y])].max end end #ここまではOK end puts dp[-1]