Submission #6050569
Source Code Expand
n=int(input()) p=[0]+list(map(int,input().split())) sp=sum(p) dp=[[0]*(sp+1) for i in range(n+1)] dp[0][0]=1 for i in range(1,n+1): for j in range(sp+1): if p[i]==j: # i問解いた時の合計点がjであるときdp[i][j]=1 dp[i][j]=1 if dp[i-1][j]==1: # i-1問解いた時に合計点がj,i問目は解かない dp[i][j]=1 if dp[i-1][j-p[i]]==1: # i-1問解いた時に合計点がj-p[i],i問目を解く dp[i][j]=1 print(dp[n].count(1)) # n問後の結果はdp[n](解いたり解かなかったり)
Submission Info
Submission Time | |
---|---|
Task | A - コンテスト |
User | soldout |
Language | Python (3.4.3) |
Score | 2 |
Code Size | 558 Byte |
Status | AC |
Exec Time | 310 ms |
Memory | 7412 KB |
Judge Result
Set Name | All | ||
---|---|---|---|
Score / Max Score | 2 / 2 | ||
Status |
|
Set Name | Test Cases |
---|---|
All | 00, 01, 02, 90, 91 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00 | AC | 19 ms | 3064 KB |
01 | AC | 88 ms | 4084 KB |
02 | AC | 310 ms | 7412 KB |
90 | AC | 17 ms | 3064 KB |
91 | AC | 17 ms | 3064 KB |