Submission #2895429
Source Code Expand
from collections import defaultdict N,W = map(int, input().split()) WV = [] for i in range(N): WV.append(list(map(int, input().split()))) dp = defaultdict(int) dp[0] = 0 for w,v in WV: for nw, nv in list(dp.items()): if nw+w <= W: dp[nw+w] = max(dp[nw+w], nv+v) print(max(dp.values()))
Submission Info
Submission Time | |
---|---|
Task | D - Simple Knapsack |
User | polarbear08 |
Language | Python (3.4.3) |
Score | 400 |
Code Size | 348 Byte |
Status | AC |
Exec Time | 80 ms |
Memory | 3828 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
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 | AC | 25 ms | 3316 KB |
antigreedy1 | AC | 24 ms | 3316 KB |
antigreedy2 | AC | 24 ms | 3316 KB |
example0 | AC | 20 ms | 3316 KB |
example1 | AC | 20 ms | 3316 KB |
example2 | AC | 20 ms | 3316 KB |
example3 | AC | 20 ms | 3316 KB |
quarter0 | AC | 80 ms | 3828 KB |
quarter1 | AC | 66 ms | 3828 KB |
quarter2 | AC | 35 ms | 3444 KB |
rand0 | AC | 20 ms | 3316 KB |
rand1 | AC | 21 ms | 3316 KB |
rand2 | AC | 21 ms | 3316 KB |
smallw0 | AC | 21 ms | 3316 KB |
smallw1 | AC | 21 ms | 3316 KB |
smallw2 | AC | 26 ms | 3316 KB |