PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#CC0000017. Đếm bộ ba giảm nghiêm ngặt (Enemy is weak)
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 bộ ba giảm nghiêm ngặt (Enemy is weak)
Enemy is weak
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Given a sequence of pairwise distinct integers, count triples of positions satisfying . The positions need not be consecutive.
Input
The first line contains . The next line contains pairwise distinct positive integers .
Output
Print one 64-bit integer: the number of qualifying index triples.
Subtasks
- Subtask 1 (20 points): ; for every ; all are pairwise distinct.
- Subtask 2 (30 points): ; for every ; all are pairwise distinct.
- Subtask 3 (50 points): ; for every ; all are pairwise distinct.
Examples
Input
4
10 8 3 1
Output
4
Explanation
The array is strictly decreasing, so every choice of three positions qualifies. The four triples are , , , and . Hence the output is .