BOJ::2293 동전 1

시사점

이해(x)

설계, 손 코딩(x)

복잡도

손 코딩 후 문제 리뷰(x)

구현(x)

함수 List

업데이트 되는 변수

실제 구현

#include<bits/stdc++.h>
#define endl '\n'
#define fi first
#define se second
#define rep(i,a,b) for(int i=a;i<b;i++)
#define r_rep(i,a,b) for(int i=a;i>b;i--)
const int MAXN = 100;
using namespace std;

int n, k;
int coin[MAXN], dp[MAXN];
void process(){
    cin >> n >> k;
    rep(i, 0, n) cin >> coin[i];

    dp[0] = 1;
    for(int i = 0; i < n; i++)
        for(int j = coin[i]; j <= k; j++)
            dp[j] += dp[j-coin[i]];

    cout << dp[k] << endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    process();
    return 0;
}

구현 후 코드리뷰 + 예제 돌려보기(x)

디버깅(x)

좋은 코드

최적화