AtCoder Beginner Contest 054

Submission #1353922

Source codeソースコード

N, A, B = map(int, input().split())
a = [(a,b,c) for i in range(N) for a,b,c in [map(int, input().split())]]
inf = 10**10
dp = [[inf]*1000 for i in range(1000)]
price = inf
dp[0][0] = 0
s = set(((0,0),))

for i in range(1, N+1):
    ai, bi, ci = a[i-1]
    ns = s.copy()
    for _a, _b in s:
        _c = dp[_a][_b]
        na, nb = _a+ai, _b+bi
        dp[na][nb] = min(dp[na][nb], ci+_c)
        ns.add((na,nb))
        if (na)*B == (nb)*A:
            price = min(price, dp[na][nb])
    s = ns

print(price if price != inf else -1)

Submission

Task問題 D - Mixing Experiment
User nameユーザ名 htkb
Created time投稿日時
Language言語 Python3 (3.4.3)
Status状態 WA
Score得点 0
Source lengthソースコード長 554 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
Sample - sample_01.txt,sample_02.txt
All 0 / 400 sample_01.txt,sample_02.txt,subtask_1_01.txt,subtask_1_02.txt,subtask_1_03.txt,subtask_1_04.txt,subtask_1_05.txt,subtask_1_06.txt,subtask_1_07.txt,subtask_1_08.txt,subtask_1_09.txt,subtask_1_10.txt,subtask_1_11.txt,subtask_1_12.txt,subtask_1_13.txt,subtask_1_14.txt,subtask_1_15.txt,subtask_1_16.txt,subtask_1_17.txt,subtask_1_18.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
sample_01.txt AC 33 ms 10868 KB
sample_02.txt AC 33 ms 10868 KB
subtask_1_01.txt AC 33 ms 10868 KB
subtask_1_02.txt AC 33 ms 10868 KB
subtask_1_03.txt AC 33 ms 10868 KB
subtask_1_04.txt AC 40 ms 10996 KB
subtask_1_05.txt AC 42 ms 11124 KB
subtask_1_06.txt AC 59 ms 11476 KB
subtask_1_07.txt AC 72 ms 11952 KB
subtask_1_08.txt AC 86 ms 12056 KB
subtask_1_09.txt AC 118 ms 12712 KB
subtask_1_10.txt AC 159 ms 12824 KB
subtask_1_11.txt AC 200 ms 13136 KB
subtask_1_12.txt AC 361 ms 14688 KB
subtask_1_13.txt AC 300 ms 14800 KB
subtask_1_14.txt WA
subtask_1_15.txt AC 300 ms 14756 KB
subtask_1_16.txt AC 322 ms 14808 KB
subtask_1_17.txt WA
subtask_1_18.txt AC 324 ms 14728 KB