Submission #10405625


Source Code Expand

#include<bits/stdc++.h>
using namespace std;

using ll = long long;

//constant
const ll MOD = 1e+9 + 7;
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// view vector
template<typename T> void view(T e) { std::cout << e << std::endl; }
template<typename T> void view(const std::vector<T>& v) { for (const auto& e : v) { std::cout << e << " "; } std::cout << std::endl; }
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

// ***************************************

int main(void) {

    int n, k;
    cin >> n >> k;
    vector<int> A(n);
    for (auto& a : A) {
        cin >> a;
    }

    vector<bool> dp_win(k+1);
	for(int i = k-1; i >= 0; i--) {
		for (auto& a : A) {
			if (i + a > k) continue;
			if (!dp_win[i + a]) {
				dp_win[i] = true;
				break;
			}
		}
	}

	cout << (dp_win[0] ? "First" : "Second") << endl;

	return 0;
}

Submission Info

Submission Time
Task K - Stones
User ytaka_tech
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1437 Byte
Status AC
Exec Time 9 ms
Memory 256 KB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 28
Set Name Test Cases
All 0_00, 0_01, 0_02, 0_03, 0_04, 0_05, 1_00, 1_01, 1_02, 1_03, 1_04, 1_05, 1_06, 1_07, 1_08, 1_09, 1_10, 1_11, 1_12, 1_13, 1_14, 1_15, 1_16, 1_17, 1_18, 1_19, 1_20, 1_21
Case Name Status Exec Time Memory
0_00 AC 1 ms 256 KB
0_01 AC 1 ms 256 KB
0_02 AC 1 ms 256 KB
0_03 AC 1 ms 256 KB
0_04 AC 1 ms 256 KB
0_05 AC 2 ms 256 KB
1_00 AC 1 ms 256 KB
1_01 AC 2 ms 256 KB
1_02 AC 1 ms 256 KB
1_03 AC 8 ms 256 KB
1_04 AC 8 ms 256 KB
1_05 AC 9 ms 256 KB
1_06 AC 6 ms 256 KB
1_07 AC 6 ms 256 KB
1_08 AC 6 ms 256 KB
1_09 AC 6 ms 256 KB
1_10 AC 6 ms 256 KB
1_11 AC 6 ms 256 KB
1_12 AC 6 ms 256 KB
1_13 AC 6 ms 256 KB
1_14 AC 6 ms 256 KB
1_15 AC 6 ms 256 KB
1_16 AC 6 ms 256 KB
1_17 AC 6 ms 256 KB
1_18 AC 6 ms 256 KB
1_19 AC 6 ms 256 KB
1_20 AC 6 ms 256 KB
1_21 AC 6 ms 256 KB