結果

問題 No.2693 Sword
ユーザー nikoro256nikoro256
提出日時 2024-03-22 21:56:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 813 bytes
コンパイル時間 185 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 68,156 KB
最終ジャッジ日時 2024-03-22 21:56:19
合計ジャッジ時間 2,844 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 36 ms
53,460 KB
testcase_03 AC 37 ms
53,460 KB
testcase_04 AC 36 ms
53,460 KB
testcase_05 AC 38 ms
53,460 KB
testcase_06 AC 36 ms
53,460 KB
testcase_07 AC 36 ms
53,460 KB
testcase_08 AC 37 ms
53,460 KB
testcase_09 AC 50 ms
55,584 KB
testcase_10 AC 39 ms
53,460 KB
testcase_11 AC 43 ms
55,584 KB
testcase_12 AC 37 ms
53,460 KB
testcase_13 AC 45 ms
53,460 KB
testcase_14 AC 39 ms
53,460 KB
testcase_15 AC 49 ms
61,628 KB
testcase_16 AC 54 ms
63,872 KB
testcase_17 AC 53 ms
63,704 KB
testcase_18 AC 47 ms
61,628 KB
testcase_19 AC 47 ms
61,756 KB
testcase_20 AC 55 ms
66,092 KB
testcase_21 AC 59 ms
68,156 KB
testcase_22 AC 54 ms
64,172 KB
testcase_23 AC 49 ms
63,884 KB
testcase_24 AC 37 ms
53,460 KB
testcase_25 AC 36 ms
53,460 KB
testcase_26 AC 37 ms
53,460 KB
testcase_27 AC 37 ms
53,460 KB
testcase_28 AC 37 ms
53,460 KB
testcase_29 AC 38 ms
53,460 KB
testcase_30 AC 38 ms
53,460 KB
testcase_31 AC 38 ms
53,460 KB
testcase_32 AC 57 ms
63,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,P,K=map(int,input().split())
counttwo=0
ones=[]
dat=[]
for _ in range(N):
    t,b=map(int,input().split())
    if t==2:
        counttwo+=1
    else:
        ones.append(b)
    dat.append([t,b])
ones.sort(reverse=True)
ans=0
for i in range(min(counttwo+1,K+1)):
    use=K-i
    if len(ones)>=use:
        lis=[]
        mul=1
        twocount=0
        count=0
        for j in range(N-1,-1,-1):
            if dat[j][0]==2:
                if twocount<i:
                    mul*=2
                    twocount+=1
                    if mul>10**18:
                        mul=10**18+1
            else:
                lis.append(mul*dat[j][1])
        lis.sort(reverse=True)
        tmp=P*mul+sum(lis[:use])
        if tmp>10**18:
            print(-1)
            exit(0)
        ans=max(ans,tmp)
print(ans)
0