use std::io::*; fn dfs( i: usize, m: i64, turn: usize, a: &mut [i64], memo: &mut Vec>, ) -> (i64, i64) { if i == a.len() { return (0, 0); } if memo[i][turn] != (-1, -1) { return memo[i][turn]; } if a[i] == 1 { if turn == 0 { let mut res = dfs(i + 1, m, 1, a, memo); res.0 += 1 - m; memo[i][turn] = res; return res; } else { let mut res = dfs(i + 1, m, 0, a, memo); res.1 += 1 - m; memo[i][turn] = res; return res; } } else if a[i] == 2 || a[i] == 3 { if turn == 0 { // 次のターンにする let mut res1 = dfs(i + 1, m, 1, a, memo); res1.0 += a[i] - m; let mut res2 = dfs(i + 1, m, 0, a, memo); res2.0 += a[i] - 1; res2.1 += 1 - m; if res1.0 > res2.0 { memo[i][turn] = res1; return res1; } memo[i][turn] = res2; return res2; } else { let mut res1 = dfs(i + 1, m, 0, a, memo); res1.1 += a[i] - m; let mut res2 = dfs(i + 1, m, 1, a, memo); res2.1 += a[i] - 1; res2.0 += 1 - m; if res1.1 > res2.1 { memo[i][turn] = res1; return res1; } memo[i][turn] = res2; return res2; } } else { if turn == 0 { let mut res = dfs(i + 1, m, 0, a, memo); res.0 += a[i] - 1; res.1 += 1 - m; memo[i][turn] = res; return res; } else { let mut res = dfs(i + 1, m, 1, a, memo); res.0 += 1 - m; res.1 += a[i] - 1; memo[i][turn] = res; return res; } } } fn main() { let mut s: String = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let mut itr = s.trim().split_whitespace(); let n: usize = itr.next().unwrap().parse().unwrap(); let m: i64 = itr.next().unwrap().parse().unwrap(); let mut a: Vec = (0..n) .map(|_| itr.next().unwrap().parse().unwrap()) .collect(); let mut memo: Vec> = vec![vec![(-1, -1); 2]; n]; // 1だったら強制分岐、2か3だったら選べる、それ以外は分岐しない let score = dfs(0, m, 0, &mut a, &mut memo); if score.0 > score.1 { println!("First"); } else { println!("Second"); } }