問題一覧 > 通常問題

No.2330 Eat Slime

レベル : / AI推定難易度 : 2000 / 実行時間制限 : 1ケース 4.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 46
作問者 : dyktr_06 / テスター : Nafmo2 firiexp tyawanmusi hikikomori sepa38 Seed57_cash
お気に入りにしたユーザー ProblemId : 9518 / 自分の提出
問題文最終更新日: 2023-05-27 00:00:23
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
MMA Contest 015 (順位表) の他の問題:

Problem Statement

$N$ slimes are lined up in a row from left to right.

The color of the $i$-th slime from the left is $C_i$. (Colors are treated as integers.)

You may perform the following operation between $0$ and $N$ times, inclusive.

  • Eat the slime at the leftmost position. The eaten slime disappears, and you gain $X$ points.

In addition to the score obtained from the above operations, you can gain additional score based on the final arrangement of slimes after all operations have been performed.

There are $M$ scoring items: if the color of the $A_j$-th slime from the left is $B_j$, you gain $Y_j$ points. (If the $A_j$-th slime from the left does not exist, you cannot gain the score.)

Find the maximum score you can obtain.


Constraints

  • $1 \leq N, M \leq 2 \times 10^5$
  • $0 \leq X \leq 100$
  • $1 \leq C_i \leq 5$
  • $1 \leq A_j \leq N$
  • $1 \leq B_j \leq 5$
  • $1 \leq Y_j \leq 100$
  • All input values are integers.

Input

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

$N$ $M$ $X$  
$C_1$ $C_2$ ... $C_N$  
$A_1$ $B_1$ $Y_1$
$A_2$ $B_2$ $Y_2$
$\vdots$

$A_M$ $B_M$ $Y_M$

Output

Output the answer to the problem on a single line.

Sample

Sample 1
Input
5 5 1
1 2 3 2 1
1 3 3
2 3 4
3 2 5
4 1 1
5 1 2
Output
11

By eating a slime $1$ time, you gain $1$ point, and since items $2, 3, 4$ are satisfied, you gain an additional $10$ points, for a total of $11$ points.

Sample 2
Input
3 6 0
1 2 3
1 1 10
1 1 10
1 2 20
1 2 20
1 3 30
1 3 30
Output
60

Note that identical items may appear multiple times.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。