問題一覧 > 通常問題

No.992 Counting Longest Increasing Subsequences

レベル : / AI推定難易度 : 1425 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 84
作問者 : %20 / テスター : kotatsugame
お気に入りにしたユーザー ProblemId : 3784 / 自分の提出
問題文最終更新日: 2020-03-08 16:57:30
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
yukicoder contest 237 (順位表) の他の問題:

Problem Statement

You are given an integer sequence $A=(A_1,A_2,\cdots,A_N)$ consisting of $N$ elements.
Find the total number of ways to take a longest increasing subsequence of $A$.
Even if the extracted subsequences are equal as sequences, they are counted as different ways if the sets of chosen positions differ.

In other words, among the integer sequences $I$ satisfying $1\le I_1\lt I_2\lt\cdots\lt I_M\le N$ and $A_{I_1}\lt A_{I_2}\lt\cdots\lt A_{I_M}$, find the number of those whose number of elements $M$ is maximum.

Output the answer modulo $10^9+7$.

Input

$N$
$A_1$ $A_2$ $\cdots$ $A_N$

The input satisfies the following constraints.

  • $N,A_i$ are integers
  • $1\le N\le2\times 10^5$
  • $-10^9\le A_i\le10^9$

Output

Output the total number of ways to take a longest increasing subsequence of $A$, modulo $10^9+7$.

Sample

Sample 1
Input
5
1 4 2 5 3
Output
3

There are the following $3$ ways to take a longest increasing subsequence.

  • $(A_1,A_2,A_4)=(1,4,5)$
  • $(A_1,A_3,A_4)=(1,2,5)$
  • $(A_1,A_3,A_5)=(1,2,3)$
Sample 2
Input
3
1 1 2
Output
2

There are the following $2$ ways to take a longest increasing subsequence. Note that these are counted as different.

  • $(A_1,A_3)=(1,2)$
  • $(A_2,A_3)=(1,2)$
Sample 3
Input
12
1 1 2 2 3 1 2 4 3 3 4 4
Output
40

There are lots of subsequences of the form $(1,2,3,4)$.

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