結果
| 問題 |
No.1416 ショッピングモール
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-03-08 17:32:51 |
| 言語 | Ruby (3.4.1) |
| 結果 |
AC
|
| 実行時間 | 121 ms / 1,000 ms |
| コード長 | 459 bytes |
| コンパイル時間 | 46 ms |
| コンパイル使用メモリ | 7,552 KB |
| 実行使用メモリ | 16,384 KB |
| 最終ジャッジ日時 | 2024-10-10 04:55:01 |
| 合計ジャッジ時間 | 3,293 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
コンパイルメッセージ
Main.rb:1: warning: assigned but unused variable - n Syntax OK
ソースコード
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