1N, S, M = map(int, input().split())
2P = list(map(int, input().split()))
3dp = [[False]*(M+1) for _ in range(N+1)]
4
5dp[0][S] = True
6
7for i in range(1, N+1):
8 for j in range(M+1):
9 if dp[i-1][j]:
10 if 0 <= j-P[i-1] <= M:
11 dp[i][j-P[i-1]] = True
12 if 0 <= j+P[i-1] <= M:
13 dp[i][j+P[i-1]] = True
14result = -1
15for i in range(M+1):
16 if dp[N][i]:
17 result = i
18print (result)
- 인터넷에서 접근을 참고했다