Submission #2894480


Source Code Expand

N,W = map(int, input().split())
WV = [[0,0]]
for i in range(N):
    WV.append(list(map(int, input().split())))

W1 = WV[0][0]
for i in range(N):
    WV[i][0] -= W1
    

dp = [[0 for _ in range(W+1)] for _ in range(N+1)]

W = W-N*W1

for n in range(1,N+1):
    for w in range(W+1):
        if w<WV[n][0]:
            dp[n][w] = dp[n-1][w]
        else:
            dp[n][w] = max(dp[n-1][w],
                           dp[n-1][w-WV[n][0]]+WV[n][1])

print(dp[N][W])

Submission Info

Submission Time
Task D - Simple Knapsack
User polarbear08
Language Python (3.4.3)
Score 0
Code Size 487 Byte
Status TLE
Exec Time 2127 ms
Memory 528536 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 4
AC × 10
TLE × 6
Set Name Test Cases
Sample example0, example1, example2, example3
All antigreedy0, antigreedy1, antigreedy2, example0, example1, example2, example3, quarter0, quarter1, quarter2, rand0, rand1, rand2, smallw0, smallw1, smallw2
Case Name Status Exec Time Memory
antigreedy0 TLE 2124 ms 515504 KB
antigreedy1 TLE 2125 ms 521264 KB
antigreedy2 TLE 2125 ms 526512 KB
example0 AC 17 ms 3064 KB
example1 AC 17 ms 3064 KB
example2 AC 18 ms 3064 KB
example3 AC 17 ms 3064 KB
quarter0 AC 399 ms 13556 KB
quarter1 AC 322 ms 12020 KB
quarter2 AC 110 ms 4972 KB
rand0 TLE 2127 ms 528536 KB
rand1 TLE 2127 ms 524440 KB
rand2 TLE 2127 ms 521240 KB
smallw0 AC 53 ms 3828 KB
smallw1 AC 69 ms 3828 KB
smallw2 AC 34 ms 3316 KB