結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー tsubametsubame
提出日時 2017-03-24 23:25:17
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
TLE  
実行時間 -
コード長 688 bytes
コンパイル時間 847 ms
コンパイル使用メモリ 10,868 KB
実行使用メモリ 12,764 KB
最終ジャッジ日時 2023-09-20 03:53:19
合計ジャッジ時間 4,284 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
12,276 KB
testcase_01 AC 17 ms
7,824 KB
testcase_02 AC 17 ms
7,936 KB
testcase_03 AC 16 ms
7,792 KB
testcase_04 AC 16 ms
7,912 KB
testcase_05 AC 16 ms
7,780 KB
testcase_06 AC 17 ms
7,776 KB
testcase_07 AC 17 ms
7,792 KB
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def calc_score(c, i, x, y, max_x, max_y, score, F):
    if i == len(c):
        return F * (max_x + max_y - x - y) + score
    elif c[i][0] + x > max_x or c[i][1] + y > max_y:
        return calc_score(c, i+1, x, y, max_x, max_y, score, F)
    else:
        return min(calc_score(c, i+1, x, y, max_x, max_y, score, F), calc_score(c, i+1, x+c[i][0], y+c[i][1], max_x, max_y, score+c[i][2], F))

X, Y, N, F = list(map(int, input().split()))
c = []

for i in range(N):
    tmp = list(map(int, input().split()))
    if (tmp[0] + tmp[1]) * F <= tmp[2]:
        continue
    c.append(tmp)

if len(c):
    score = calc_score(c, 0, 0, 0, X, Y, 0, F)
else:
    score = F * (X + Y)

print(score)


0