結果

問題 No.1416 ショッピングモール
ユーザー masashi0217masashi0217
提出日時 2021-03-08 17:32:51
言語 Ruby
(3.2.2)
結果
AC  
実行時間 110 ms / 1,000 ms
コード長 459 bytes
コンパイル時間 115 ms
コンパイル使用メモリ 11,368 KB
実行使用メモリ 20,452 KB
最終ジャッジ日時 2023-07-31 11:25:20
合計ジャッジ時間 4,350 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
15,028 KB
testcase_01 AC 80 ms
15,156 KB
testcase_02 AC 79 ms
15,088 KB
testcase_03 AC 81 ms
15,228 KB
testcase_04 AC 81 ms
15,140 KB
testcase_05 AC 82 ms
15,032 KB
testcase_06 AC 79 ms
15,176 KB
testcase_07 AC 81 ms
15,084 KB
testcase_08 AC 80 ms
15,260 KB
testcase_09 AC 79 ms
15,236 KB
testcase_10 AC 81 ms
15,272 KB
testcase_11 AC 84 ms
15,228 KB
testcase_12 AC 80 ms
15,048 KB
testcase_13 AC 81 ms
15,560 KB
testcase_14 AC 82 ms
15,352 KB
testcase_15 AC 87 ms
15,564 KB
testcase_16 AC 80 ms
15,428 KB
testcase_17 AC 83 ms
15,724 KB
testcase_18 AC 82 ms
15,528 KB
testcase_19 AC 82 ms
15,712 KB
testcase_20 AC 83 ms
15,568 KB
testcase_21 AC 108 ms
19,364 KB
testcase_22 AC 110 ms
19,652 KB
testcase_23 AC 109 ms
20,452 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:1: warning: assigned but unused variable - n
Syntax OK

ソースコード

diff #

n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
a = a.sort
now_kai = 0
min_ans = 0
while true
    max = 2 ** now_kai
    i = 0
    ok = true
    while ok
        min_ans += a.pop * now_kai
        #print "{a}" + " " + "#{min_ans}" + " " +"#{now_kai}" +" "+"#{i}"+ "\n"
        i += 1
        ok = false if a == []
        break if max == i
        #i += 1
    end
    break if ok == false
    now_kai += 1
    #puts "^^^^^^^^^^^^^^"
end
puts min_ans
0