Problem p03170 (C++)

Buggy submission (status: Runtime Error):
/*
                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                    ___/`---'\___
                  .' \\|     |// '.
                 / \\|||  :  |||// \
                / _||||| -:- |||||- \
               |   | \\\  -  /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
             ___'. .'  /--.--\  `. .'___
          ."" '<  `.___\_<|>_/___.' >' "".
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` /  /
     =====`-.____`.___ \_____/___.-`___.-'=====
                       `=---='

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Vikash Kumar @ Codechef/codeforces
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <bits/stdc++.h>

#define ll long long int
#define ll_MAX LLONG_MAX
#define ll_MIN LLONG_MIN
#define pi 3.14159265358979323846
#define count_1(n) __builtin_popcountll(n)
#define MOD 1000000007
#define MAX 1e9
#define MIN -1e9
#define itoc(c) ((char)(((int)'0') + c))
#define mid(s, e) (s + (e - s) / 2)
const int MX = 10010896;
const int lmt = 3164;
const int N = 10000001;
#define fastio                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL)
using namespace std;
ll extgcd(ll a, ll b, ll &x, ll &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  } else {
    int g = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return g;
  }
}
ll modpow(ll a, ll b) {
  ll res = 1;
  a %= MOD;
  for (; b; b >>= 1) {
    if (b & 1)
      res = res * a % MOD;
    a = a * a % MOD;
  }
  return res;
}

bool dp[100005];

inline void solve() {
  /*<logic>*/
  int n, k;
  cin >> n >> k;
  int arr[n];
  for (int i = 0; i < n; i++)
    cin >> arr[i];
  memset(dp, false, sizeof(dp));
  for (int stone = 0; stone <= k; stone++) {
    for (int a : arr) {
      if (stone >= a && !dp[stone - a]) {
        dp[stone] = true;
        break;
      }
    }
  }
  if (dp[k])
    cout << "First" << endl;
  else
    cout << "Second" << endl;
  /*</logic>*/
}

int main() {
  cout << fixed << setprecision(12);
  // freopen("input.txt", "r", stdin);
  fastio;
  ll t = 1, tc = 1;
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout);
#endif
  // cin>>t;
  while (t--) {
    solve();
  }
  return 0;
}

Fixed submission:
/*
                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                    ___/`---'\___
                  .' \\|     |// '.
                 / \\|||  :  |||// \
                / _||||| -:- |||||- \
               |   | \\\  -  /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
             ___'. .'  /--.--\  `. .'___
          ."" '<  `.___\_<|>_/___.' >' "".
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` /  /
     =====`-.____`.___ \_____/___.-`___.-'=====
                       `=---='

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Vikash Kumar @ Codechef/codeforces
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <bits/stdc++.h>

#define ll long long int
#define ll_MAX LLONG_MAX
#define ll_MIN LLONG_MIN
#define pi 3.14159265358979323846
#define count_1(n) __builtin_popcountll(n)
#define MOD 1000000007
#define MAX 1e9
#define MIN -1e9
#define itoc(c) ((char)(((int)'0') + c))
#define mid(s, e) (s + (e - s) / 2)
const int MX = 10010896;
const int lmt = 3164;
const int N = 10000001;
#define fastio                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL)
using namespace std;
ll extgcd(ll a, ll b, ll &x, ll &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  } else {
    int g = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return g;
  }
}
ll modpow(ll a, ll b) {
  ll res = 1;
  a %= MOD;
  for (; b; b >>= 1) {
    if (b & 1)
      res = res * a % MOD;
    a = a * a % MOD;
  }
  return res;
}

bool dp[100005];

inline void solve() {
  /*<logic>*/
  int n, k;
  cin >> n >> k;
  int arr[n];
  for (int i = 0; i < n; i++)
    cin >> arr[i];
  memset(dp, false, sizeof(dp));
  for (int stone = 0; stone <= k; stone++) {
    for (int a : arr) {
      if (stone >= a && !dp[stone - a]) {
        dp[stone] = true;
        break;
      }
    }
  }
  if (dp[k])
    cout << "First" << endl;
  else
    cout << "Second" << endl;
  /*</logic>*/
}

int main() {
  cout << fixed << setprecision(12);
  // freopen("input.txt", "r", stdin);
  fastio;
  ll t = 1, tc = 1;
  // cin>>t;
  while (t--) {
    solve();
  }
  return 0;
}