結果

問題 No.2693 Sword
ユーザー june19312june19312
提出日時 2024-03-22 22:12:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 179 ms / 2,000 ms
コード長 1,730 bytes
コンパイル時間 198 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 78,096 KB
最終ジャッジ日時 2024-03-22 22:12:55
合計ジャッジ時間 3,381 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 55 ms
53,460 KB
testcase_02 AC 39 ms
53,460 KB
testcase_03 AC 37 ms
53,460 KB
testcase_04 AC 37 ms
53,460 KB
testcase_05 AC 37 ms
53,460 KB
testcase_06 AC 37 ms
53,460 KB
testcase_07 AC 37 ms
53,460 KB
testcase_08 AC 37 ms
53,460 KB
testcase_09 AC 101 ms
76,128 KB
testcase_10 AC 57 ms
66,272 KB
testcase_11 AC 71 ms
75,360 KB
testcase_12 AC 37 ms
53,460 KB
testcase_13 AC 60 ms
68,320 KB
testcase_14 AC 52 ms
64,192 KB
testcase_15 AC 83 ms
75,960 KB
testcase_16 AC 62 ms
70,376 KB
testcase_17 AC 89 ms
75,896 KB
testcase_18 AC 57 ms
66,280 KB
testcase_19 AC 91 ms
75,700 KB
testcase_20 AC 79 ms
74,684 KB
testcase_21 AC 102 ms
76,320 KB
testcase_22 AC 94 ms
75,700 KB
testcase_23 AC 77 ms
75,036 KB
testcase_24 AC 38 ms
53,460 KB
testcase_25 AC 37 ms
53,460 KB
testcase_26 AC 36 ms
53,460 KB
testcase_27 AC 37 ms
53,460 KB
testcase_28 AC 38 ms
53,460 KB
testcase_29 AC 39 ms
53,460 KB
testcase_30 AC 38 ms
53,460 KB
testcase_31 AC 37 ms
53,460 KB
testcase_32 AC 179 ms
78,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,P,K = map(int,input().split())

d1,d2 = {},{}
d1[0] = P

for i in range(N):
    T,B = map(int,input().split())
    
    if len(d1):
        for ind,val in d1.items():
            if ind not in d2:
                d2[ind] = val
            else:
                d2[ind] = max(d2[ind],val)
            
            if T == 1:
                nex = val+B
                if ind+1 <= K:
                    if ind+1 not in d2:
                        d2[ind+1] = nex
                    else:
                        d2[ind+1] = max(d2[ind+1],nex)
            else:
                nex = val*2
                if ind+1 <= K:
                    if ind+1 not in d2:
                        d2[ind+1] = nex
                    else:
                        d2[ind+1] = max(d2[ind+1],nex)
        if K in d2:
            if d2[K] > 10**18:
                print(-1)
                exit()
        d1 = {}
    else:
        for ind,val in d2.items():
            if ind not in d1:
                d1[ind] = val
            else:
                d1[ind] = max(d1[ind],val)
            
            if T == 1:
                nex = val+B
                if ind+1 <= K:
                    if ind+1 not in d1:
                        d1[ind+1] = nex
                    else:
                        d1[ind+1] = max(d1[ind+1],nex)
            else:
                nex = val*2
                if ind+1 <= K:
                    if ind+1 not in d1:
                        d1[ind+1] = nex
                    else:
                        d1[ind+1] = max(d1[ind+1],nex)
        if K in d1:
            if d1[K] > 10**18:
                print(-1)
                exit()
        d2 = {}

if len(d1):
    print(d1[K])
else:
    print(d2[K])

0