結果

問題 No.5001 排他的論理和でランニング
ユーザー letrangerjpletrangerjp
提出日時 2018-03-16 23:08:53
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,094 ms / 1,500 ms
コード長 349 bytes
コンパイル時間 31 ms
実行使用メモリ 22,972 KB
スコア 25,900,396
最終ジャッジ日時 2020-03-12 19:31:40
ジャッジサーバーID
(参考情報)
judge10 /
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 960 ms
22,312 KB
testcase_01 AC 61 ms
12,716 KB
testcase_02 AC 96 ms
13,724 KB
testcase_03 AC 220 ms
16,220 KB
testcase_04 AC 808 ms
22,972 KB
testcase_05 AC 121 ms
15,072 KB
testcase_06 AC 576 ms
17,568 KB
testcase_07 AC 667 ms
18,408 KB
testcase_08 AC 128 ms
18,876 KB
testcase_09 AC 11 ms
11,644 KB
testcase_10 AC 62 ms
14,464 KB
testcase_11 AC 113 ms
15,428 KB
testcase_12 AC 160 ms
14,364 KB
testcase_13 AC 303 ms
18,980 KB
testcase_14 AC 259 ms
17,632 KB
testcase_15 AC 143 ms
15,220 KB
testcase_16 AC 50 ms
12,764 KB
testcase_17 AC 59 ms
13,740 KB
testcase_18 AC 206 ms
17,036 KB
testcase_19 AC 222 ms
15,412 KB
testcase_20 AC 114 ms
13,960 KB
testcase_21 AC 71 ms
13,980 KB
testcase_22 AC 35 ms
12,400 KB
testcase_23 AC 25 ms
12,160 KB
testcase_24 AC 234 ms
14,932 KB
testcase_25 AC 964 ms
19,000 KB
testcase_26 AC 717 ms
17,964 KB
testcase_27 AC 329 ms
15,544 KB
testcase_28 AC 509 ms
18,268 KB
testcase_29 AC 762 ms
18,824 KB
testcase_30 AC 38 ms
12,716 KB
testcase_31 AC 339 ms
18,008 KB
testcase_32 AC 91 ms
14,108 KB
testcase_33 AC 477 ms
19,260 KB
testcase_34 AC 748 ms
22,932 KB
testcase_35 AC 452 ms
18,080 KB
testcase_36 AC 940 ms
21,808 KB
testcase_37 AC 657 ms
18,624 KB
testcase_38 AC 116 ms
14,032 KB
testcase_39 AC 92 ms
15,072 KB
testcase_40 AC 296 ms
15,984 KB
testcase_41 AC 34 ms
12,784 KB
testcase_42 AC 151 ms
15,476 KB
testcase_43 AC 223 ms
16,112 KB
testcase_44 AC 780 ms
19,056 KB
testcase_45 AC 859 ms
19,256 KB
testcase_46 AC 1,094 ms
19,420 KB
testcase_47 AC 183 ms
15,332 KB
testcase_48 AC 127 ms
14,204 KB
testcase_49 AC 214 ms
18,396 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, M = gets.split.map &:to_i
A = gets.split.map(&:to_i).sort
m = N - M
ans = A.dup
res = A.inject(:^)
A.group_by{|a|Math.log2(a).floor}.each{|k, v|
  oddp = res & 2**k != 0
  v.pop if oddp
  v.each{|n|
    res ^= n
    ans.delete_at(ans.bsearch_index{|a|a>n})
    m -= 1
    if m == 0
      puts ans*" "
      exit
    end
  }
}
puts ans.max(M)*" "
0