File tree 1 file changed +35
-0
lines changed
1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ import java .util .*;
2
+ import java .io .*;
3
+
4
+ public class Stones {
5
+
6
+ public static void main (String [] args ) throws IOException {
7
+ BufferedReader br = new BufferedReader (new InputStreamReader (System .in ));
8
+ String [] s = br .readLine ().split (" " );
9
+ int n = Integer .parseInt (s [0 ]);
10
+ int k = Integer .parseInt (s [1 ]);
11
+ s = br .readLine ().split (" " );
12
+ int [] arr = new int [n ];
13
+
14
+ for (int i = 0 ; i < n ; i ++)
15
+ arr [i ] = Integer .parseInt (s [i ]);
16
+
17
+ Arrays .sort (arr );
18
+
19
+ boolean [] dp = new boolean [k + 1 ];
20
+
21
+ for (int i = 1 ; i <= k ; i ++) {
22
+ for (int j = 0 ; j < n && arr [j ] <= i ; j ++) {
23
+ if (!dp [i - arr [j ]]) {
24
+ dp [i ] = true ;
25
+ break ;
26
+ }
27
+ }
28
+ }
29
+ if (dp [k ])
30
+ System .out .println ("First" );
31
+ else
32
+ System .out .println ("Second" );
33
+ }
34
+
35
+ }
You can’t perform that action at this time.
0 commit comments