結果

問題 No.1416 ショッピングモール
ユーザー masashi0217masashi0217
提出日時 2021-03-08 17:32:51
言語 Ruby
(3.3.0)
結果
AC  
実行時間 116 ms / 1,000 ms
コード長 459 bytes
コンパイル時間 170 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 16,256 KB
最終ジャッジ日時 2024-04-18 11:43:32
合計ジャッジ時間 3,070 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
12,160 KB
testcase_01 AC 77 ms
12,160 KB
testcase_02 AC 88 ms
12,288 KB
testcase_03 AC 80 ms
12,288 KB
testcase_04 AC 78 ms
12,288 KB
testcase_05 AC 73 ms
12,288 KB
testcase_06 AC 77 ms
12,160 KB
testcase_07 AC 84 ms
12,288 KB
testcase_08 AC 75 ms
12,288 KB
testcase_09 AC 81 ms
12,160 KB
testcase_10 AC 77 ms
12,288 KB
testcase_11 AC 77 ms
12,416 KB
testcase_12 AC 77 ms
12,160 KB
testcase_13 AC 87 ms
12,288 KB
testcase_14 AC 84 ms
12,416 KB
testcase_15 AC 82 ms
12,544 KB
testcase_16 AC 78 ms
12,544 KB
testcase_17 AC 81 ms
12,544 KB
testcase_18 AC 84 ms
12,416 KB
testcase_19 AC 84 ms
12,672 KB
testcase_20 AC 85 ms
12,672 KB
testcase_21 AC 116 ms
16,256 KB
testcase_22 AC 110 ms
16,256 KB
testcase_23 AC 104 ms
16,256 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