PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#TP0000056. Đếm cặp chỉ số thỏa chuỗi bất đẳng thức (Yet Another Problem About Pairs Satisfying an Inequality)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Đếm cặp chỉ số thỏa chuỗi bất đẳng thức (Yet Another Problem About Pairs Satisfying an Inequality)
Yet Another Problem About Pairs Satisfying an Inequality
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
You are given an integer array , with positions numbered from to .
An ordered pair of indices qualifies if the four numbers , , , satisfy the strict chain
Count the valid index pairs. Positions in this inequality are 1-based, not 0-based.
Input
- The first line contains integer : the array length.
- The second line contains exactly integers .
Output
Print one integer: the number of index pairs satisfying .
Subtasks
- Subtask 1 (20 points): ; for every .
- Subtask 2 (30 points): ; for every .
- Subtask 3 (50 points): ; for every .
Examples
Input
8
1 1 2 3 8 2 1 4
Output
3
Explanation
The valid index pairs are , , and . For instance, pair has , , and satisfies . No other pair satisfies all four strict inequalities, so print .