PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#FT0000081. Bộ ba tăng nghiêm ngặt (Increasing Triples)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Bộ ba tăng nghiêm ngặt (Increasing Triples)
Increasing Triples
Source: Luogu
Version: Phuoc Hung OJ Extended
Problem Statement
Given an integer sequence , count triples of distinct positions satisfying
Triples are identified by their index triples, so identical values chosen from different positions count separately. Both inequalities must be strict; equal values do not satisfy the requirement.
Input
The first line contains .
The second line contains exactly integers .
Output
Print one integer: the number of valid increasing triples of positions.
Subtasks
- Subtask 1 (30 points): ; for every .
- Subtask 2 (30 points): ; for every .
- Subtask 3 (40 points): ; for every .
Examples
Input
5
1 2 2 3 4
Output
7
Explanation
The two occurrences of value at positions and are separate choices. The valid index triples are , , , , , and .
Thus the answer is . A triple using both occurrences of is invalid because the inequalities are strict.