PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#CC0000022. Đếm dãy con tăng độ dài K+1 (Subsequences)
HỌC THEO LỘ TRÌNH
2 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Đếm dãy con tăng độ dài K+1 (Subsequences)
Subsequences
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Given a permutation of , count ways to choose exactly increasing indices whose corresponding values are strictly increasing. Different index selections count separately. The answer is guaranteed not to exceed .
Input
The first line contains integers . Exactly integers follow (possibly on separate lines), forming a permutation of .
Output
Print one 64-bit integer: the number of strictly increasing subsequences of length exactly . Do not take a modulus.
Subtasks
- Subtask 1 (20 points): ; ; the sequence is a permutation of ; the number of target subsequences does not exceed .
- Subtask 2 (30 points): ; ; the sequence is a permutation of ; the number of target subsequences does not exceed .
- Subtask 3 (50 points): ; ; the sequence is a permutation of ; the number of target subsequences does not exceed .
Examples
Input
5 2
1
2
3
5
4
Output
7
Explanation
We need strictly increasing subsequences of length . The seven value triples are , , , , , , and . A selection containing followed by is not increasing.