結果

問題 No.1416 ショッピングモール
ユーザー U S
提出日時 2021-03-05 21:34:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 66 ms / 1,000 ms
コード長 664 bytes
コンパイル時間 288 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 72,448 KB
最終ジャッジ日時 2024-10-07 00:44:07
合計ジャッジ時間 2,306 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

# import sys
# input = sys.stdin.readline
def mp():return map(int,input().split())
def lmp():return list(map(int,input().split()))
import math
import bisect
from copy import deepcopy as dc
from itertools import accumulate
from collections import Counter, defaultdict, deque
def ceil(U,V):return (U+V-1)//V
def modf1(N,MOD):return (N-1)%MOD+1
inf = int(1e30)
mod = int(1e9+7)

n = int(input())
a = lmp()
a.sort(reverse=True)
u = []
for i in range(1,17):
    u.append(2**i-1)
ans = 0
cnt = 0
for i in range(17):
    for j in range(cnt, u[i]):
        if cnt >= n:break
        else:
            ans += i*a[cnt]
            cnt += 1
    if cnt >= n:break
print(ans)

0