fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int n, k;
  4. int a[105];
  5. int dp[100005][2];
  6.  
  7. int solve(int i, int ok) {
  8. if (dp[i][ok] != -1) return dp[i][ok];
  9. int cur;
  10. if (ok == 0) cur = 1;
  11. else cur = 0;
  12. if (ok == 0) {
  13. for (int j = 1; j <= n; j++)
  14. if (i >= a[j])
  15. cur = min(cur, solve(i - a[j], 1 - ok));
  16. } else {
  17. for (int j = 1; j <= n; j++)
  18. if (i >= a[j])
  19. cur = max(cur, solve(i - a[j], 1 - ok));
  20. }
  21. return dp[i][ok] = cur;
  22. }
  23.  
  24. main() {
  25. ios_base::sync_with_stdio(false);
  26. cin.tie(0); cout.tie(0);
  27. freopen("TEST.inp", "r", stdin);
  28. freopen("TEST.out", "w", stdout);
  29. cin >> n >> k;
  30. for (int i = 1; i <= n; i++) cin >> a[i];
  31.  
  32. memset(dp, -1, sizeof(dp));
  33.  
  34. if (solve(k, 0) == 0) cout << "First" << '\n';
  35. else cout << "Second" << '\n';
  36.  
  37. return 0;
  38. }
  39.  
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
Standard output is empty