結果

問題 No.1360 [Zelkova 4th Tune] 協和音
ユーザー gmm_teagmm_tea
提出日時 2021-01-22 21:54:49
言語 Ruby
(3.3.0)
結果
AC  
実行時間 482 ms / 2,000 ms
コード長 593 bytes
コンパイル時間 452 ms
コンパイル使用メモリ 11,360 KB
実行使用メモリ 17,640 KB
最終ジャッジ日時 2023-08-27 18:46:00
合計ジャッジ時間 15,863 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
15,148 KB
testcase_01 AC 76 ms
15,148 KB
testcase_02 AC 77 ms
15,220 KB
testcase_03 AC 77 ms
15,064 KB
testcase_04 AC 76 ms
15,344 KB
testcase_05 AC 77 ms
15,064 KB
testcase_06 AC 78 ms
14,968 KB
testcase_07 AC 77 ms
15,096 KB
testcase_08 AC 78 ms
15,088 KB
testcase_09 AC 78 ms
14,976 KB
testcase_10 AC 77 ms
15,204 KB
testcase_11 AC 77 ms
15,068 KB
testcase_12 AC 78 ms
15,216 KB
testcase_13 AC 77 ms
15,220 KB
testcase_14 AC 78 ms
15,104 KB
testcase_15 AC 78 ms
15,228 KB
testcase_16 AC 77 ms
15,216 KB
testcase_17 AC 78 ms
15,288 KB
testcase_18 AC 77 ms
15,028 KB
testcase_19 AC 76 ms
15,168 KB
testcase_20 AC 77 ms
15,140 KB
testcase_21 AC 76 ms
15,220 KB
testcase_22 AC 78 ms
15,024 KB
testcase_23 AC 118 ms
15,352 KB
testcase_24 AC 167 ms
16,124 KB
testcase_25 AC 480 ms
17,572 KB
testcase_26 AC 81 ms
15,088 KB
testcase_27 AC 78 ms
15,224 KB
testcase_28 AC 470 ms
17,552 KB
testcase_29 AC 98 ms
15,200 KB
testcase_30 AC 122 ms
15,420 KB
testcase_31 AC 121 ms
15,368 KB
testcase_32 AC 89 ms
15,140 KB
testcase_33 AC 478 ms
17,420 KB
testcase_34 AC 482 ms
17,640 KB
testcase_35 AC 470 ms
17,500 KB
testcase_36 AC 479 ms
17,492 KB
testcase_37 AC 468 ms
17,484 KB
testcase_38 AC 470 ms
17,420 KB
testcase_39 AC 471 ms
17,436 KB
testcase_40 AC 470 ms
17,580 KB
testcase_41 AC 470 ms
17,548 KB
testcase_42 AC 470 ms
17,252 KB
testcase_43 AC 77 ms
15,288 KB
testcase_44 AC 470 ms
17,572 KB
testcase_45 AC 77 ms
15,092 KB
testcase_46 AC 468 ms
17,544 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n=gets.to_i
a=gets.split.map(&:to_i)
b=[]
n.times do
  b << gets.split.map(&:to_i)
end
# n=18
# a=[1000000000]*n
# b=[]
# n.times do
#   b << [1000000000]*n
# end
d=[0,a[0]]
dk=2
dkk=1
dki=0
m=a[0]
mi=1
2.upto(2**n-1) do |di|
  if di==dk
    dki+=1
    dkk=dk
    dk*=2
  end
  # dki は今の2進数桁数 - 1
  # dk は次に位が上がるとき
  c=a[dki]+d[di-dkk]
  (dki-1).downto(0) do |i|
    if di[i]==1
      c+=b[dki][i]
    end
  end
  d << c
#  p [di.to_s(2),c]
  if m<c
    m=c
    mi=di
  end
end
puts m
l=[]
n.times do |i|
  if mi[i]==1
    l << i+1
  end
end
puts l.join(" ")
0