結果

問題 No.798 コレクション
ユーザー tomarint2
提出日時 2019-03-15 23:24:48
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 347 bytes
コンパイル時間 81 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 16,768 KB
最終ジャッジ日時 2024-07-01 21:42:57
合計ジャッジ時間 5,149 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10 TLE * 1 -- * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
a=[0]*N
b=[0]*N
for i in range(N):
    a[i],b[i]=map(int,input().split())

def buy(n, history):
    if n == (N+1)*2//3:
        return 0
    cost = []
    for i in range(N):
        if (history & (1 << i)) != 0:
            continue
        cost.append(a[i]+b[i]*n + buy(n+1, history|(1<<i)))
    return min(cost)

print(buy(0, 0))
0