結果

問題 No.1416 ショッピングモール
ユーザー mesame3993
提出日時 2021-12-09 01:30:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 181 ms / 1,000 ms
コード長 553 bytes
コンパイル時間 261 ms
コンパイル使用メモリ 82,168 KB
実行使用メモリ 81,408 KB
最終ジャッジ日時 2024-07-16 12:20:06
合計ジャッジ時間 3,002 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
  from sys import stdin
  readline = stdin.readline
  n = int(readline())
  A = list(map(int, readline().split()))
  A.sort(reverse=True)
  ans = 0
  def keta(x):
    ret = 0
    while x > 0:
      ret += 1
      x //= 2
    return ret
  k = 0
  now = 0
  for i in range(n):
    now += 1
    error(i, k)
    ans += A[i] * k
    if now == 2**k:
      k += 1
      now = 0

  print(ans)
  
if __name__ == "__main__":
  import sys
  readline = sys.stdin.readline
  def error(*args, end='\n'):
    print(*args, end=end, file=sys.stderr)
  main()
0