Untitled

mail@pastecode.io avatar
unknown
c_cpp
7 months ago
1.3 kB
0
Indexable
Never
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100100;
const int maxn2 = 1e2+7;
typedef long long ll;

#define ios ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0)
#define pb(x) push_back(x)
#define all(x) sort(x.begin() , x.end())

void dbg(){
     cerr << endl;
}
template<typename H, typename... T> void dbg(H h, T... t){
     cerr << h << ", ";
     dbg(t...);
}
#define er(...) cerr << __LINE__ << " <" << #__VA_ARGS__ << ">: ", dbg(__VA_ARGS__)
int a[maxn2] , n;
int dp[maxn];
bool win(int k){
    // er(k , dp[k]);
     if(dp[k] != -1){
          return dp[k];
     }
     dp[k] = 0;
     for(int i = 0 ; i < n ; i++){
          if(k >= a[i])
               if(win(k - a[i]) == 0){
                    //er(k - a[i]);
                    if(k - a[i] == 1) cout << "ha";
               //    cout << k - a[i] << '\n';
                    dp[k] = 1;
                    break;
               }
     }
     return dp[k];
}
int main(){
     ios;
     int k;
     cin >> n >> k;
     for(int i = 0 ; i < maxn ; i++) dp[i] = -1;
     for(int i = 0 ; i < n ; i++){
          cin >> a[i];
     }
     for(int i = 0 ; i < a[0] ; i++) dp[i] = 0;
     (win(k) == 1) ? cout << "First" : cout << "Second";

     return 0;
}