题库练习 Enemy is weak
← 上一题 下一题 →

A7987 | Enemy is weak

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

The Romans have attacked again. This time they are much more than the Persians but Shapur is ready to defeat them. He says: "A lion is never afraid of a hundred sheep".

Nevertheless Shapur has to find weaknesses in the Roman army to defeat them. So he gives the army a weakness number.

In Shapur's opinion the weakness of an army is equal to the number of triplets $i,j,k$ such that $i<j<k$ and $a_{i}>a_{j}>a_{k}$ where $a_{x}$ is the power of man standing at position $x$ . The Roman army has one special trait — powers of all the people in it are distinct.

Help Shapur find out how weak the Romans are.
罗马人再次发动进攻。这次他们比波斯人强大得多,但沙普尔已经做好了打败他们的准备。他说:"一头狮子永远不怕一百只绵羊"。

然而,沙普尔必须找到罗马军队的弱点才能打败他们。于是,他给军队编了一个弱点号码。

沙普尔认为,一支军队的弱点等于 i < j < k 和 ai > aj > ak 的三联数 i, j, k ,其中 ax 是站在 x 位置上的人的力量。罗马军队有一个特点--军队中所有人的力量都是不同的。

帮助沙普尔找出罗马人的弱点。

输入格式

The first line of input contains a single number $n$ ( $3<=n<=10^{6}$ ) — the number of men in Roman army. Next line contains $n$ different positive integers $a_{i}$ ( $1<=i<=n,1<=a_{i}<=10^{9}$ ) — powers of men in the Roman army.
输入
第一行包含一个数字 $n$ ( $3<=n<=10^{6}$ ) - 罗马军队的人数。下一行包含 n 不同的正整数 $a_{i}$ ( $1<=i<=n,1<=a_{i}<=10^{9}$ ) - 罗马军队人数的幂

输出格式

A single integer number, the weakness of the Roman army.

Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cout (also you may use %I64d).
输出
一个整数,即罗马军队的弱点。
请不要使用 %lld specificator 在 C++ 中读写 64 位整数。最好使用 cout(也可以使用 %I64d)。

输入输出样例

输入 #1
3
3 2 1
输出 #1
1
输入 #2
3
2 3 1
输出 #2
0
输入 #3
4
10 8 3 1
输出 #3
4
输入 #4
4
1 5 4 3
输出 #4
1
C++ 编辑器
输入
输出