結果

問題 No.1738 What's in the box?
ユーザー simansiman
提出日時 2021-11-22 18:30:42
言語 Ruby
(3.3.0)
結果
AC  
実行時間 86 ms / 2,000 ms
コード長 362 bytes
コンパイル時間 194 ms
コンパイル使用メモリ 11,400 KB
実行使用メモリ 15,572 KB
最終ジャッジ日時 2023-09-06 11:57:59
合計ジャッジ時間 8,372 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,100 KB
testcase_01 AC 78 ms
15,192 KB
testcase_02 AC 78 ms
15,180 KB
testcase_03 AC 81 ms
15,564 KB
testcase_04 AC 81 ms
15,544 KB
testcase_05 AC 81 ms
15,500 KB
testcase_06 AC 81 ms
15,444 KB
testcase_07 AC 81 ms
15,560 KB
testcase_08 AC 81 ms
15,348 KB
testcase_09 AC 82 ms
15,420 KB
testcase_10 AC 82 ms
15,388 KB
testcase_11 AC 81 ms
15,532 KB
testcase_12 AC 80 ms
15,316 KB
testcase_13 AC 77 ms
15,316 KB
testcase_14 AC 77 ms
15,232 KB
testcase_15 AC 77 ms
15,284 KB
testcase_16 AC 76 ms
15,124 KB
testcase_17 AC 76 ms
15,148 KB
testcase_18 AC 76 ms
15,280 KB
testcase_19 AC 77 ms
15,112 KB
testcase_20 AC 77 ms
15,192 KB
testcase_21 AC 78 ms
15,088 KB
testcase_22 AC 77 ms
15,084 KB
testcase_23 AC 77 ms
15,184 KB
testcase_24 AC 77 ms
15,248 KB
testcase_25 AC 80 ms
15,080 KB
testcase_26 AC 78 ms
15,072 KB
testcase_27 AC 77 ms
15,128 KB
testcase_28 AC 76 ms
15,068 KB
testcase_29 AC 77 ms
15,368 KB
testcase_30 AC 76 ms
15,256 KB
testcase_31 AC 77 ms
15,320 KB
testcase_32 AC 77 ms
15,144 KB
testcase_33 AC 81 ms
15,384 KB
testcase_34 AC 81 ms
15,384 KB
testcase_35 AC 80 ms
15,356 KB
testcase_36 AC 81 ms
15,392 KB
testcase_37 AC 82 ms
15,572 KB
testcase_38 AC 85 ms
15,572 KB
testcase_39 AC 81 ms
15,328 KB
testcase_40 AC 83 ms
15,316 KB
testcase_41 AC 82 ms
15,424 KB
testcase_42 AC 81 ms
15,316 KB
testcase_43 AC 81 ms
15,568 KB
testcase_44 AC 82 ms
15,440 KB
testcase_45 AC 82 ms
15,492 KB
testcase_46 AC 81 ms
15,496 KB
testcase_47 AC 82 ms
15,420 KB
testcase_48 AC 86 ms
15,520 KB
testcase_49 AC 83 ms
15,424 KB
testcase_50 AC 81 ms
15,440 KB
testcase_51 AC 81 ms
15,472 KB
testcase_52 AC 80 ms
15,396 KB
testcase_53 AC 76 ms
15,260 KB
testcase_54 AC 77 ms
15,056 KB
testcase_55 AC 76 ms
15,096 KB
testcase_56 AC 76 ms
15,292 KB
testcase_57 AC 76 ms
15,056 KB
testcase_58 AC 76 ms
15,168 KB
testcase_59 AC 78 ms
15,372 KB
testcase_60 AC 78 ms
15,320 KB
testcase_61 AC 77 ms
15,364 KB
testcase_62 AC 78 ms
15,232 KB
testcase_63 AC 77 ms
15,284 KB
testcase_64 AC 77 ms
15,236 KB
testcase_65 AC 77 ms
15,320 KB
testcase_66 AC 78 ms
15,164 KB
testcase_67 AC 77 ms
15,240 KB
testcase_68 AC 77 ms
15,144 KB
testcase_69 AC 78 ms
15,240 KB
testcase_70 AC 78 ms
15,088 KB
testcase_71 AC 77 ms
15,144 KB
testcase_72 AC 78 ms
15,244 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, M = gets.split.map(&:to_i)
W = gets.split.map(&:to_i)
gcd = W.inject(&:gcd)
S = W.sum

if gcd.zero?
  puts W.join(' ')
  exit
end

NW = W.map { |x| x / gcd }

def f(r)
  NW.map { |x| x * r }.sum <= M
end

ok = 1
ng = 10 ** 9

while (ok - ng).abs >= 2
  r = (ok + ng) / 2

  if f(r)
    ok = r
  else
    ng = r
  end
end

puts NW.map { |x| x * ok }.join(' ')
0