結果

問題 No.1416 ショッピングモール
ユーザー kappybarkappybar
提出日時 2021-04-29 15:39:39
言語 Go
(1.22.1)
結果
AC  
実行時間 286 ms / 1,000 ms
コード長 366 bytes
コンパイル時間 10,875 ms
コンパイル使用メモリ 211,740 KB
実行使用メモリ 5,696 KB
最終ジャッジ日時 2023-09-23 00:18:34
合計ジャッジ時間 12,988 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 4 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 6 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 17 ms
4,376 KB
testcase_12 AC 3 ms
4,380 KB
testcase_13 AC 18 ms
4,376 KB
testcase_14 AC 22 ms
4,380 KB
testcase_15 AC 33 ms
4,376 KB
testcase_16 AC 21 ms
4,380 KB
testcase_17 AC 40 ms
4,376 KB
testcase_18 AC 39 ms
4,376 KB
testcase_19 AC 43 ms
4,376 KB
testcase_20 AC 40 ms
4,376 KB
testcase_21 AC 211 ms
5,680 KB
testcase_22 AC 219 ms
5,684 KB
testcase_23 AC 286 ms
5,696 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main
import ("fmt"
        "sort")

func main() {
  var n int
  fmt.Scan(&n)
  a := make([]int,n)
  for i := 0;i < n; i++ {
    fmt.Scan(&a[i])
  }
  sort.Sort(sort.Reverse(sort.IntSlice(a)))
  f := 0
  pow2 := 1
  ans := 0
  for i := 0;i < n;i ++ {
    ans += f * a[i]
    pow2 --
    if pow2 == 0 {
      f ++
      pow2 = 1<<f
    }
  }
  fmt.Print(ans)
}
0