fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. typedef long long ll;
  6. typedef pair<int, int> ii;
  7.  
  8. const int INF = 1e9;
  9. const ll LINF = 1e18;
  10.  
  11. const int N = 1e2 + 5;
  12. const int K = 1e5 + 5;
  13.  
  14. int n, k;
  15. int a[N];
  16.  
  17. bool dp[K]; // dp[i] = Với cọc có i viên đá thì người đi trước sẽ thắng hay thua
  18.  
  19. int main() {
  20. ios::sync_with_stdio(false);
  21. cin.tie(nullptr);
  22. cin >> n >> k;
  23. for (int i = 1; i <= n; i++) cin >> a[i];
  24.  
  25. // Giả sử người chơi nhìn thấy được trước tương lai
  26. // Họ sẽ chọn nước đi mà ép đối phương vào trạng thái thua
  27. for (int i = 0; i <= k; i++) {
  28. dp[i] = 0;
  29. for (int j = 1; j <= n; j++) {
  30. if (i >= a[j]) dp[i] |= !dp[i - a[j]];
  31. }
  32. }
  33.  
  34. cout << (dp[k] ? "First" : "Second") << '\n';
  35. }
  36.  
Success #stdin #stdout 0s 5300KB
stdin
2 4
2 3
stdout
First