P26786 [AtCoder] Card Collection
省选
题目描述

Problem Description

There are $ N $ cards on the table, each numbered from $ 1 $ to $ N $.

Two players will play the following game using these cards:

  • Players take turns picking one card at a time from the table.
  • The game ends when all cards have been taken.

Afterward, the score is calculated according to the following rules to determine the winner:

  • The player who takes the $i\ (1\ \leq\ i\ \leq\ N)$ card earns a score of $ s_i $.
  • For $i\ =\ 1,\ 2,\ ...,\ M$, if a player takes both the $ a_i $ card and the $ b_i $ card, they earn a score of $ c_i $.

The player with the higher total score wins. If the total scores are the same, the second player wins.

When both players act optimally to win, which player will be the winner?

Input Format

The input is given from the standard input in the following format:

$ N $ $ M $ $ s_1 $ $ s_2 $ $ ... $ $ s_N $ $ a_1 $ $ b_1 $ $ c_1 $ $ a_2 $ $ b_2 $ $ c_2 $ $ : $ $ a_M $ $ b_M $ $ c_M $

Output Format

Output First if the first player wins, or Second if the second player wins.

Sample Input and Output

Sample Input #1

4 4
1 20 30 10
1 2 40
1 3 30
1 4 50
2 3 100

Sample Output #1

First

Sample Input #2

6 10
16 14 5 2 6 11
1 2 17
1 3 8
1 6 7
2 3 2
2 4 1
2 6 9
3 4 3
3 5 2
4 5 17
5 6 26

Sample Output #2

Second

Sample Input #3

10 9
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000
1 2 1000000000
2 3 1000000000
3 4 1000000000
4 5 1000000000
5 6 1000000000
6 7 1000000000
7 8 1000000000
8 9 1000000000
9 10 1000000000

Sample Output #3

Second

Notes/Hints

Constraints

  • All inputs are integers.
  • $2\ \leq\ N\ \leq\ 10^5$
  • $1\ \leq\ M\ \leq\ 10^5$
  • $1\ \leq\ a_i\ <\ b_i\ \leq\ N$
  • $1\ \leq\ s_i,\ c_i\ \leq\ 10^9$

Sample Explanation 1

  • The first player takes the $ 1 $ card first.
  • Considering the case where the second player takes the $ 2 $ card next.
  • Then, the first player takes the $ 3 $ card.
  • The second player has no choice but to take the $ 4 $ card.
    The total scores are as follows, and the first player wins:
  • The first player took the $ 1 $ and $ 3 $ cards, so their total score is $1\ +\ 30\ +\ 30\ =\ 61$.
  • The second player took the $ 2 $ and $ 4 $ cards, so their total score is $20\ +\ 10\ =\ 30$.
    The first player wins in other cases as well by picking cards optimally.
输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
4 4 1 20 30 10 1 2 40 1 3 30 1 4 50 2 3 100
样例输出
First