2024-09-12 13:25:40

 

이번 단계가 저번 단계의 결과값을 포함하고 있음을 이용한 문제이다

수업듣고 써야지

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.Threading.Channels;
 
namespace real연습
{
    internal class Program
    {
        static void Main(string[] args)
        {
            int[] arr = Array.ConvertAll(Console.ReadLine().Trim().Split(), int.Parse);
            int[] dp = new int[arr[1+ 1];
            dp[0= 1;
 
            for (int i = 0; i < arr[0]; i++)
            {
                int coin = int.Parse(Console.ReadLine());
                for (int j = coin; j <= arr[1]; j++)
                {
                    dp[j] += dp[j - coin];
                }
            }
            Console.WriteLine(dp[arr[1]]);
        }
    }
}
cs

'코끼리' 카테고리의 다른 글

[백준] 2839 : 설탕 배달 [DP]  (0) 2024.09.13