結果

問題 No.1037 exhausted
ユーザー Kiri8128Kiri8128
提出日時 2020-04-24 22:26:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 111 ms / 2,000 ms
コード長 628 bytes
コンパイル時間 180 ms
コンパイル使用メモリ 82,148 KB
実行使用メモリ 76,864 KB
最終ジャッジ日時 2024-04-23 03:37:56
合計ジャッジ時間 2,480 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,644 KB
testcase_01 AC 38 ms
53,140 KB
testcase_02 AC 38 ms
54,104 KB
testcase_03 AC 38 ms
54,116 KB
testcase_04 AC 37 ms
52,896 KB
testcase_05 AC 38 ms
52,304 KB
testcase_06 AC 37 ms
53,004 KB
testcase_07 AC 39 ms
52,760 KB
testcase_08 AC 38 ms
53,196 KB
testcase_09 AC 38 ms
52,068 KB
testcase_10 AC 37 ms
53,564 KB
testcase_11 AC 38 ms
52,868 KB
testcase_12 AC 106 ms
76,684 KB
testcase_13 AC 103 ms
76,512 KB
testcase_14 AC 109 ms
76,620 KB
testcase_15 AC 102 ms
76,640 KB
testcase_16 AC 108 ms
76,864 KB
testcase_17 AC 111 ms
76,592 KB
testcase_18 AC 104 ms
76,580 KB
testcase_19 AC 106 ms
76,736 KB
testcase_20 AC 69 ms
73,476 KB
testcase_21 AC 69 ms
73,604 KB
testcase_22 AC 68 ms
73,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def calc(S, v, w):
    T = sorted(S[:] + [(min(s[0] + v, V), s[1] + w) for s in S], key = lambda x: -x[0])
    U = []
    prew = 1 << 100
    prev = 1 << 100
    for t in T:
        if t[1] < prew:
            if t[0] == prev:
                U.pop()
            U.append(t)
            prew = t[1]
            prev = t[0]
    return U

N, V, L = map(int, input().split())
S = [(V, 0)]
prex = 0
for _ in range(N):
    x, v, w = map(int, input().split())
    dx = x - prex
    prex = x
    S = [(v - dx, w) for v, w in S if v >= dx]
    S = calc(S, v, w)

dx = L - prex
A = [w for v, w in S if v >= dx]
print(min(A) if A else -1)
0