結果
問題 |
No.698 ペアでチームを作ろう
|
ユーザー |
|
提出日時 | 2021-02-19 07:59:11 |
言語 | Ruby (3.4.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 592 bytes |
コンパイル時間 | 641 ms |
コンパイル使用メモリ | 7,296 KB |
実行使用メモリ | 18,816 KB |
最終ジャッジ日時 | 2024-09-15 12:29:09 |
合計ジャッジ時間 | 3,727 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 TLE * 1 |
other | -- * 12 |
コンパイルメッセージ
Syntax OK
ソースコード
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