結果

問題 No.1017 Reiwa Sequence
ユーザー yuruhiyayuruhiya
提出日時 2021-04-02 21:05:28
言語 Crystal
(1.11.2)
結果
AC  
実行時間 939 ms / 2,000 ms
コード長 365 bytes
コンパイル時間 23,151 ms
コンパイル使用メモリ 255,212 KB
実行使用メモリ 72,248 KB
最終ジャッジ日時 2023-08-25 11:02:54
合計ジャッジ時間 47,352 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,472 KB
testcase_01 AC 2 ms
4,496 KB
testcase_02 AC 3 ms
4,492 KB
testcase_03 AC 3 ms
4,412 KB
testcase_04 AC 3 ms
4,520 KB
testcase_05 AC 2 ms
4,504 KB
testcase_06 AC 2 ms
4,496 KB
testcase_07 AC 3 ms
4,452 KB
testcase_08 AC 3 ms
4,500 KB
testcase_09 AC 3 ms
4,632 KB
testcase_10 AC 83 ms
23,884 KB
testcase_11 AC 3 ms
4,476 KB
testcase_12 AC 828 ms
37,252 KB
testcase_13 AC 833 ms
37,044 KB
testcase_14 AC 3 ms
4,556 KB
testcase_15 AC 3 ms
4,660 KB
testcase_16 AC 2 ms
4,540 KB
testcase_17 AC 4 ms
4,872 KB
testcase_18 AC 3 ms
4,596 KB
testcase_19 AC 72 ms
23,768 KB
testcase_20 AC 72 ms
23,660 KB
testcase_21 AC 78 ms
23,824 KB
testcase_22 AC 81 ms
23,800 KB
testcase_23 AC 83 ms
23,648 KB
testcase_24 AC 83 ms
23,652 KB
testcase_25 AC 78 ms
23,740 KB
testcase_26 AC 73 ms
23,744 KB
testcase_27 AC 73 ms
23,704 KB
testcase_28 AC 78 ms
23,816 KB
testcase_29 AC 79 ms
23,720 KB
testcase_30 AC 81 ms
23,732 KB
testcase_31 AC 78 ms
23,652 KB
testcase_32 AC 86 ms
23,660 KB
testcase_33 AC 77 ms
23,772 KB
testcase_34 AC 74 ms
23,676 KB
testcase_35 AC 65 ms
23,816 KB
testcase_36 AC 67 ms
23,912 KB
testcase_37 AC 84 ms
23,724 KB
testcase_38 AC 80 ms
23,780 KB
testcase_39 AC 79 ms
23,812 KB
testcase_40 AC 939 ms
70,264 KB
testcase_41 AC 899 ms
70,096 KB
testcase_42 AC 901 ms
72,132 KB
testcase_43 AC 902 ms
72,248 KB
testcase_44 AC 281 ms
10,780 KB
testcase_45 AC 860 ms
72,244 KB
testcase_46 AC 889 ms
63,204 KB
testcase_47 AC 810 ms
47,956 KB
testcase_48 AC 883 ms
47,208 KB
testcase_49 AC 293 ms
15,024 KB
testcase_50 AC 274 ms
14,040 KB
testcase_51 AC 3 ms
4,380 KB
testcase_52 AC 78 ms
23,660 KB
testcase_53 AC 75 ms
23,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

m = read_line.to_i
a = read_line.split.map(&.to_i)
n = {22, m}.min
hash = {} of Int32 => Int32
b1, b2 = nil, nil
(0...1 << n).each { |b|
  sum = (0...n).sum { |i| a[i] * b.bit(i) }
  if hash.has_key?(sum)
    b1, b2 = hash[sum], b
  end
  hash[sum] = b
}
if b1 && b2
  puts "Yes", (0...m).map { |i| a[i] * (b1.bit(i) <=> b2.bit(i)) }.join(' ')
else
  puts "No"
end
0