---
# System prepended metadata

title: 12979 - Diet
tags: [combination]

---

# 12979 - Diet
>author: Utin
###### tags: `combination`

---

## Brief
See the code below

## Solution 0

```c=
#include <stdio.h>

int cake[21];
int n, k, c = 0;
void eat(int index, int sum);

int main() {
    scanf("%d %d", &n, &k);
    for(int i = 0; i < n; i++) {
        scanf("%d", &cake[i]);
    }
    for(int i = 0; i < n; i++) {
        if(c == 1) break;
        eat(i, 0);
    }
    if(c == 0) printf("NO\n");
}

void eat(int index, int sum) {
    sum += cake[index];
    if(sum == k) {
        printf("YES\n");
        c = 1;
    }
    else if(sum < k) {
        for(int i = index + 1/*設成0會超時*/; i < n; i++) {
            if(c == 1) break;
            eat(i, sum);
        }
    }
}
// By Utin
```

## Reference